What are the void expressions in C# programming language?

 Posted by Goud.Kv on 9/3/2014 | Category: C# Interview questions | Views: 319 | Points: 40
Answer:

Void expressions are the empty valued expressions. They do not have any values.

Example,
Console.WriteLine("Hi");
The above code prints the stuff present in the double quotes but we didn't had any value in it.

We cannot generate complex expressions by using void expressions as operands. If we do, it will throw a compile time error.
Example,
Console.WriteLine("Hi") + 5; // Error (Compile time)
The above code will gives a compile time error as we are trying to generate a complex expression with void expression.


Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response