When overloading methods, is it possible to use a single method for multiple arguments? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

When overloading methods, is it possible to use a single method for multiple arguments?

E.g. Static void Print( int a, double a) { Console.WriteLine("Value" + a); } Static Void Main(Strings[] args) { Print (11.24); // output Value 11.24? I'm guessing that this would cause an error but wanted to see if this would work or if I could do something similar.

6th Aug 2016, 2:42 AM
Playjoy “Kungpoww” Of Death
Playjoy “Kungpoww” Of Death - avatar
2 Réponses
+ 1
hai friend, it is not possible. the method print uses two parameters int a and double a here you got a duplicate error in main method you called print(11.24) , the compiler does not found a method for print method with single parameter so you will get a compilation error. check the generics lesson in sololearn
6th Aug 2016, 5:16 AM
Aravind R S
Aravind R S - avatar
0
Thank you, although generics is about 6 lessons away atm
6th Aug 2016, 5:20 AM
Playjoy “Kungpoww” Of Death
Playjoy “Kungpoww” Of Death - avatar