C# – it called when trying to overload a function based purely on the return type

c

What is it called when trying to overload a function based purely on the return type?

ie:

Public String DoWork()

Public int DoWork()

You cannot do the above, right?

Is that called covariance?

Best Answer

It's still called a "method overload" but sometimes you'll hear the more verbose "return-type method overload." It is not possible in C#.

From the C# specification:

The signature of a method must be unique in the class in which the method is declared. The signature of a method consists of the name of the method, the number of type parameters and the number, modifiers, and types of its parameters. The signature of a method does not include the return type.