Public Function NoReturnFunVB()
End Function
.method public instance object NoReturnFunVB() cil managed
{
// Code size 3 (0x3)
.maxstack 1
.locals init ([0] object NoReturnFunVB)
IL_0000: nop
IL_0001: ldloc.0
IL_0002: ret
} // end of method Class1::NoReturnFunVB
Public Sub NoReturnSubVB()
End Sub
.method public instance void NoReturnSubVB() cil managed
{
// Code size 3 (0x3)
.maxstack 8
IL_0000: nop
IL_0001: nop
IL_0002: ret
} // end of method Class1::NoReturnSubVB
public
void NoReturnCSharp()
{
}
.method public hidebysig instance void NoReturnCSharp() cil managed
{
// Code size 2 (0x2)
.maxstack 0
IL_0000: nop
IL_0001: ret
} // end of method Class1::NoReturnCSharp
Look at these MSIL instructions, C# has the cleanest implementation of a void method; the size of the evaluation stack is 0 and there is nothing except a mandatory nop, followed by return.
VB.NET sub is next, but mysteriously it has a .maxstack 8 statement at the top, what are they thinking?? Although that does not mean the run time evaluation stack is 8, the statement is used only for static analyzer by the verifier during the assembly loading phase.
VB.NET function with no explicit return type is the ugliest. To preserve genericity, the all mighty object is used as the base type so that even if you return an arraylist of arraylists of arraylists of... is fine.