ExamVeda
Login
Home
Introduction to C Sharp
?

What does the 'void' keyword indicate in C#?

Answer & Solution
Correct Answer: Option A
void is a return type in C# that specifies a method does not return any value.

When you define a method in C#, you must declare what type of value it will return using a return type. If the method performs some actions but does not return a result to the calling code, you use void as the return type.

For example:

Example:
void PrintGreeting()
{
    Console.WriteLine("Hello, World!");
}


In this example, the method PrintGreeting() simply prints a message to the console and does not return any value.

If you try to use a return statement with a value in a void method, the compiler will throw an error, because void means "no return value".

Important Notes:

✔ Use void when your method does something but doesn't produce a result.

✔ void is commonly used in event handlers, logging methods, and other utility functions.

✔ Unlike data types like int, string, or bool, void represents the absence of a return value, not a data type.

Therefore, Option A is correct: "It does not return a value".
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Basant Anand
Basant Anand 1 year ago
How it will be an error i think you guys are providing wrong info.