Jump to content
  • Advertisement
Sign in to follow this  
Headkaze

Setting members in VB.NET without constructors

This topic is 2077 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In C# I can do the following:

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

Is there an equivalent in VB.NET?

Share this post


Link to post
Share on other sites
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"}

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!