Examveda

What is the correct way to declare a method named GetAbsoluteValue that takes an integer parameter num and returns its absolute value in C#?

A. GetAbsoluteValue(num) { return Math.Abs(num); }

B. int GetAbsoluteValue(int num) { return Math.Abs(num); }

C. GetAbsoluteValue { return Math.Abs(num); }

D. None of the above

Answer: Option B


Join The Discussion

Related Questions on Functions and Methods in C Sharp