Udostępnij za pośrednictwem


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.

Comments

  • Anonymous
    August 28, 2003
    The comment has been removed
  • Anonymous
    August 28, 2003
    The comment has been removed
  • Anonymous
    August 29, 2003
    The comment has been removed
  • Anonymous
    August 29, 2003
    The comment has been removed
  • Anonymous
    August 31, 2003
    The comment has been removed