0
Overloading or overriding c#
same method name, same parameters but different return type. what it is called as overloading or overriding.
6 ответов
+ 11
@anu We can't have the same method signature with different return type as the compiler will be confused to pick the correct method to call.
We overload a method by using different parameters and override by implement or redefine it in another class. 😉
+ 9
@anu You're welcome! 😉
Besides, glad to have a few challenges with you before this, Happy Learning in C#! 👍
+ 2
It is not overriding because overriding is about changing the body of the method.
Theorectically it should be overloading, because its method definition is changed.
However.
Changing the return type for a overloaded method is not allowed in c#.
+ 2
thank you for your time @sneeze @zephykr koo
+ 1
Correct.
If you want to work with different return types in method. You should use the generic type <T>.
Or use void as return type and make your current return type a parameter.
0
you mean this case won't work right ..! @sneeze