tags:

views:

135

answers:

3

Just of a curiosity, is there any practical use of "Void" struct

except in Reflection ?

+2  A: 

Well documentation says,

The Void structure is used in the System.Reflection namespace, but is rarely useful in a typical application. The Void structure has no members other than the ones all types inherit from the Object class.

So I doubt it.

PSU_Kardi
+3  A: 

I think, but I'm not sure, that this struct is used by the compiler to generate il for functions with void return type

Arash
+1, that's correct. System.Void can be used as-is in the C++/CLI language.
Hans Passant
+5  A: 

System.Void is the equivalent of the void keyword. Check the tool tip of void and it will display

struct System.Void

But it can't be used directly in C#, so you best ignore it.

Trying to use System.Void will generate a compilation error

error CS0673: System.Void cannot be used from C# -- use typeof(void) to get the void type object

So then, it will fall to the topic of reflection only.

Pierre-Alain Vigeant