Vidyalelo
C# Programming · Q44

Functions and Methods in C Sharp

Programming · C# Programming · question 44

Q44

What is the correct syntax to define a method named GetMax that takes two integer parameters num1 and num2 and returns the maximum of the two numbers in C#?

A.
int GetMax = (int num1, int num2) => Math.Max(num1, num2);
B.
int GetMax(int num1, int num2) { return Math.Max(num1, num2); }
Answer
C.
GetMax { return Math.Max(num1, num2); }
D.
None of the above

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board