Sunday, March 30, 2008

Auto-Implemented Properties

You do not have to declare private variables to store values of your class properties.
Before:
public class Person 
{
     private string name;
     public string Name
     {
         get { return name; }
         set { name = value; }
     } 
}
After:
public class Person 
{
     public string Name { get; set; } 
}
More Info: MSND: Auto-Implemented Properties