Curly braces in VB.NET?

by Grank December 11, 2008 12:11
Hey,
 
If you've been enjoying C# 3.0's object initializer syntax, but have to work on a VB.NET project, you might like to know that there's something similar in VB.NET 9.0.
 
You could do it like this:
 

Dim point1 As New MapPoint()

With point1

.Latitude = 0

.Longitude = 0

End With

Or now you can do it like this:

Dim point1 As New MapPoint() With {.Latitude = 0, .Longitude = 0}

 

Doesn't make a huge difference, but enough of one that I'm glad it's there!

Tags: , ,

Comments

Add comment


(Will show your Gravatar icon)

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen | Modified by Mooglegiant

About The Author

I'm a software developer and musician in Edmonton, AB.  I write mostly web-based software, primarily on the Microsoft stack.  I have an MCPD and several MCTS, but I've only been at this whole developer thing for a few years, and the truth is that I'm still learning more than knowing.  So these are my adventures and experiments and some of it will probably be blatantly wrong...  Just warning ya.