Vidyalelo
C# Programming · Q36

Functions and Methods in C Sharp

Programming · C# Programming · question 36

Q36

What is the correct way to declare a method named PrintMessage that prints a message to the console without taking any parameters or returning any value in C#?

A.
PrintMessage: { Console.WriteLine("Message"); }
B.
void PrintMessage { Console.WriteLine("Message"); }
C.
void PrintMessage() { Console.WriteLine("Message"); }
Answer
D.
PrintMessage() { Console.WriteLine("Message"); }

Answer: Option C

Solution

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