0
I'm not getting something in method overloading lesson c#
In method overloading lesson in c# it says 'You cannot overload method declarations that differ only by return type. The following declaration results in an error. int PrintName(int a) { } float PrintName(int b) { } double PrintName(int c) { }' but then this code does not result in error. i dont get it. i declare two methods with the same name and different return type and it does not result in error. Any help? https://code.sololearn.com/c4Lni0l85Ja5/?ref=app
4 Respostas
0
Error: 👇 👇
static double PrintName(int c){...}
Good: 👇 👇
static double PrintName(double c){...}
0
I'm sorry, I meant that this ( https://code.sololearn.com/c4Lni0l85Ja5/?ref=app ) code does not result in error even though I declared two methods with the same name and different return types.
0
I don't find the Statement you meant sry but I think that was meant in relationship with "static".
Because you can only do that with Static methodes.
0
Bakteria