Quantcast
Channel: dot net – Refactoring Self
Viewing all articles
Browse latest Browse all 11

Visual Basic 2010 Object and List Initialization

$
0
0

I just found this out and I am really excited about it! The With & From are cooler than ever!

Check this out:

Module Module1
Private Class TestClass
Public Property Subject As String
Public Property Grade As String
Public Property Student As String
End Class
Sub Main()
Dim myTest As New TestClass With {.Grade = "A+", .Student = "Myself", .Subject = "Advanced Chromotography"}

Dim test As New System.Collections.Generic.List(Of TestClass) From {
myTest,
New TestClass With {.Subject = "Math", .Student = "John Bowman", .Grade = "B"}}

End Sub
End Module

The With and From are now part of the declaration statement, saving even more real estate on the screen.



Viewing all articles
Browse latest Browse all 11

Trending Articles