Practice mode C#

Which pair of methods would NOT be valid overloads in the same C# class?

Correct answer C. int Get(int x) and string Get(int x)

Explanation

Overloads must differ in their signature, which consists of the method name and the number, types and kinds (ref, out, in, value) of parameters. The return type is not part of the signature, so two methods that differ only in return type clash. Changing a parameter type, adding a parameter or switching between value and ref all produce valid overloads.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.