C# 3.0 Orcas Language Features - Automatic Properties

by UnquaLe 1. October 2007 21:42

If you are developer you are probably quite used to writing classes with properties.

public class Customer
{
    private string firstname;
    public string Firstname
    {
        get { return firstname; }
        set { firstname = value; }
     }
}

 

This is a simple property and there is no logic in the getter and setter of the property. With new coming up C# 3.0 compiler provides short way to use properties with Automatic Properties feature.

When you are using C# 3.0 you can make your classes more concise, For example;

public class Customer
{
    public string Firstname { get; set; }
}

 

Yeah ! I know its cool to write a property in a line ;)

C# 3.0 Compiler will automaticly generate private fields in your class and implement a public getter / setter property implementation to it.

Bart De Smet has a great write-up on what happens under the covers when using automatic properties with the March CTP release of "Orcas".  You can read his excellent blog post on it here.

Tags: ,

Comments

8/27/2010 5:25:06 PM #

Blaine Solis

Totally realize what your stance in this issue. Even though I'd disagree on some of the finer particulars, I think you do an amazing work explaining it. Certain beats getting to investigation it on my own. Many thanks

Blaine Solis United States | Reply

8/28/2010 8:15:07 PM #

oil paintings

I wanted to say that it's nice to know that someone else also mentioned this as I had trouble finding the same info elsewhere. This was the first place that told me the answer. Thanks.

oil paintings United States | Reply

8/29/2010 9:41:06 AM #

sex cam

Why didn’t I find this post earlier? Keep up the good work!

sex cam United States | Reply

8/31/2010 8:36:48 PM #

Replica Rolex Watches

A good blog, I like! Welcome to our website to find your favorite watch, click on my name! Look forward to your visit! Thank you!

Replica Rolex Watches United States | Reply

9/2/2010 7:42:03 PM #

Capacitor for 250W MH - Floralux, 15uf/400v

No words can explain, how grateful I am upon reading your article.
Refreshing and mind blowing article makes my brain work. Thanks for
this wonderful topic.

Capacitor for 250W MH - Floralux, 15uf/400v United States | Reply

9/3/2010 1:45:00 PM #

Cam Sex

I think you have spent a lot of time to provide this quality article to us. I do not know how to thank you.

Cam Sex United States | Reply

9/3/2010 1:45:03 PM #

Girls Cam

If you think of vision and mission as an organization's head and heart, the values it holds are its soul.

Girls Cam United States | Reply

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading