I know that methods declared with void
does not return anything.
But it seems that in C#, void
is more than just a keyword, but a real type.
void
is an alias for System.Void
, like int
that is for System.Int32
.
Why am I not allowed to use that type? It does not make any sense, but these are just some thoughts about the logic.
Neither
var nothing = new System.Void();
(which says I should use void
(Not an alias?))
nor
var nothing = new void();
compiles.
It is also not possible to use something like that:
void GiveMeNothing() { }
void GiveMeNothingAgain()
{
return GiveMeNothing();
}
So what's the point with System.Void
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…