Empty Structures compile in VB 10+

Posted by Mark Hurd on Stack Overflow See other posts from Stack Overflow or by Mark Hurd
Published on 2012-09-18T02:58:42Z Indexed on 2012/09/18 3:37 UTC
Read the original article Hit count: 233

Filed under:
|

This is at least a documentation error, if not a bug.

In VB.NET prior to .NET 4.0 (i.e. VB.NET 7 through 9) an empty Structure declaration fails at compile-time with

error BC30281: Structure 'MySimpleEmpty' must contain at least one instance member variable or Event declaration.

E.g. The following two structures compile successfully in VB10, and not prior:

Structure MySimpleEmpty
End Structure

Public Structure AnotherEmpty
  Public Const StillEmpty As Boolean = True
End Structure

I note the documentation for the Error BC30281 stops at VB9, but the documentation for the Structure statement still has the datamemberdeclarations as required even as of VB11 (.NET 4.5 VS2012).

These two Structures compile in VB11 (VS2012) as well. (Thanks John Woo.)

Is there some blog entry or documentation confirming this is an intended change or a bug in VB10 and later?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about structure