skeevs::com

# geek, web 2.0, .net, gaming
@ perry.loh at gmail.com
t http://twitter.com/skeevs
f Perry Loh
 
May 08
Permalink

Object initializers vs. Constructors

Do the introduction of object initializers in VS 2008 mean the end of constructors?

Dim p As New Person With {.Name = “James Brown”, .Age = 60}

Well, no.

Constructors provide means for the class to implicate it’s required values/information during instantiation. Object initializers allows the developer to easily assign values during instantiation of the object. 

I’m sure with this feature, some developers are going to leave out constructors in favor of using this syntax. Just remember that the implications/intentions are different.

tags: object_initializers vs2008 net

Comments (View)
blog comments powered by Disqus