The mysteries of software development and networking... RSS 2.0



 Saturday, May 10, 2008

I just wasted some of my time figuring out how to do collection initialization in VB9.

C#3.0 has a new feature called collection initializer and according to a (somewhat older) post by Scott Guthrie, VB9 was slated to have it too. I guess it got cut somewhere.

Anyway this is what collection initializers look like in C#3.0:

List<int> numbers = new List<int> { 1, 2, 3, 4, 5 };

The closest thing in VB9 would be to use array initializers:

Dim numbers As New List(Of Integer)

Dim temp() As Integer = {1, 2, 3, 4, 5}

numbers.AddRange(temp)

Saturday, May 10, 2008 9:22:46 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | VB.NET
About
This blog is run by Mark Blomsma.
© Copyright 2009
Develop-One
Sign In
Statistics
Total Posts: 376
This Year: 34
This Month: 0
This Week: 1
Comments: 119
All Content © 2009, Develop-One
DasBlog theme 'Business' created by Christoph De Baene (delarou)