What happened to my () at the end of my initialization?

In VB.NET 2003, when you create an instance of a class and there are no parameters to pass to the constructor, the parentheses will not show.  You can type them, but the editor will remove them.  They didn’t disappear in VB.NET 2002.

myNewObject = New Foo()
will turn into
myNewObject = New Foo

No matter what you do, those parentheses will not remain.  Why?  I asked one of the program managers on the VB.NET team.  He said that having empty parentheses was too confusing for people.  In VB you can use empty parentheses for declaring arrays.  People would end up accidentally declaring an array of something rather than creating an instance of something.

I don’t buy it.  I think they should have left the parentheses on there.

One thought on “What happened to my () at the end of my initialization?

  1. Pingback: What the heck? More places parens aren’t required… « jim blizzard’s blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s