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
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
About
This blog is run by Mark Blomsma.
© Copyright 2008
Develop-One
Sign In
Statistics
Total Posts: 305
This Year: 49
This Month: 2
This Week: 1
Comments: 36
All Content © 2008, Develop-One
DasBlog theme 'Business' created by Christoph De Baene (delarou)