Monday, February 7, 2011

Collection initialization syntax in VB 2008?

I'm trying to determine if there's a way in Visual Basic 2008 (Express edition if that matters) to do inline collection initialization, a la JavaScript or Python:

Dim oMapping As Dictionary(Of Integer, String) = {{1,"First"}, {2, "Second"}}

I know VB2008 supports array initialization like this, but I can't seem to get it to work for collections... do I have the syntax wrong, or is it just not implemented?

  • VB 9 doesn't support this yet. However, VB 10 will.

    Michael Haren : *sigh*...that's lame
  • Hmm, that's what I was afraid of. Thanks.

    SLaks : This should be a comment.
    Ryan Corradini : Pretty sure my reply was made before comments existed. ;)

0 comments:

Post a Comment