I work with the Boise .NET Developers User Group (NETDUG — gotta luv that name). They’ve started an MCAD SIG, so I work the study guide labs along with them. I wanted to do some cross-language inheritance from VB (parent) to C# (child), just to see how MustInherit, MustOverride, etc. in VB would force the issue in C#.
I was using Notepad as my editor, and as I typed my VB class I forgot to put the parens after a subroutine name, such as
Public Sub fNoAttributes
(Simple repro example.)
I compiled the class, and what do you know… the VB .NET compiler allowed this method definition. GROAN! The VB .NET environment in VS.NET tacks the parens on there if you leave them off, knowing they should be there for consistency and all reasonableness. But no, they’re not required by the VB.NET compiler. Ugh.
I looked at the generated class using ILDASM and saw the method defined as
.method public instance void fNoAttributes() cil managed
// Code size 3 (0x3)
IL_0000: br.s IL_0002
} // end of method Foo::fNoAttributes
Just for grins I removed the parens from a C# method (again, using notepad) and the C# compiler squawked at me. Thank you, C# compiler writers!
I complained earlier about the VB.NET environment removing the parens from instance creation:
Dim f as New Foo
But for methods they tack parens on, even though the compiler doesn’t require them.
Heh. What were those VB.NET guys smokin’? Certainly not the consistency weed.