Vidyalelo
C# Programming · Q34

Functions and Methods in C Sharp

Programming · C# Programming · question 34

Q34

What is the correct way to define a method named IsEven that takes an integer parameter num and returns true if the number is even, otherwise false, in C#?

A.
IsEven(num) { return num % 2 == 0; }
B.
bool IsEven = (int num) => num % 2 == 0;
C.
bool IsEven(int num) { return num % 2 == 0; }
Answer
D.
bool IsEven { return num % 2 == 0; }

Answer: Option C

Solution

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