Just of a curiosity, is there any practical use of "Void" struct
except in Reflection ?
Just of a curiosity, is there any practical use of "Void" struct
except in Reflection ?
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.
I think, but I'm not sure, that this struct is used by the compiler to generate il for functions with void return type
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.