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

8th Aug 2022, 7:20 AM
Bakteria
Bakteria - avatar
4 Answers
0
Error: 👇 👇 static double PrintName(int c){...} Good: 👇 👇 static double PrintName(double c){...}
8th Aug 2022, 7:32 AM
Solo
Solo - avatar
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.
8th Aug 2022, 7:41 AM
Bakteria
Bakteria - avatar
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.
8th Aug 2022, 8:24 AM
Felix Alcor
Felix Alcor - avatar
0
Bakteria
8th Aug 2022, 5:08 PM
Julio