Setting members in VB.NET without constructors

Started by
1 comment, last by Headkaze 10 years, 5 months ago
In C# I can do the following:

MyClass myObject = new MyClass() { Member1 = value1, Member2 = value2, Member3 = value3 };

Is there an equivalent in VB.NET?
Advertisement

found this example

Public Class Customer

Public Id As Integer

Public Name As String

End Class

then, you can

Dim cust = New Customer() With {.Id = 2, .Name = "VB.NET 9.0"}

The Four Horsemen of Happiness have left.

That's great thanks. Never seen curly brackets used like that in VB.NET before. Is this feature only available to Visual Studio 9 (2008) and higher?

This topic is closed to new replies.

Advertisement