Practice mode C#

Given static void Show(int a, int b), which call uses named arguments correctly in C#?

Correct answer C. Show(b: 2, a: 1)

Explanation

Named arguments use the parameter name followed by a colon, so Show(b: 2, a: 1) passes 1 to a and 2 to b even though the order differs from the declaration. Names make calls with many parameters, especially booleans, easier to read. The = form would be parsed as assignments to variables a and b, not as argument names.

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.