Skip to content
October 8, 2008 / kiranpatils

using Object Initializers with Sub object

I have Two Entities like as shown below:

Address.cs

image

Employee.cs

image

Now i want to use Powerful feature of C# 3.0 object initializers. I am using it since few days but with simple types not with complex type like Employee.Address.. but its good to know that c#3.0 also supports this…Thanks to “Anders hejlsberg” for such a nice programming language…anyway lets look how we can do this..here’s the way..

image

and output is:

image

My intention of showing output is that the code works🙂 just kidding… Enjoy the new and powerful features of C#3.0…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: