Thursday, June 25, 2009

Automatic Implemented Properties in .NET 3.5

One of the cool feature that I like in .NET 3.5 is the automatic implementation of Properties in .NET 3.5. Here is a sample:

   1:  
   2: private string _name
   3:  
   4: public string Name
   5: {
   6:     get
   7:     {
   8:         return _name;
   9:     }
  10:     set
  11:     {
  12:         _name = value;
  13:     }
  14: }

Can be re-written as:

   1:  
   2: public string Name {get; set;}
   3:  

No comments:

 
Best viewed in Internet Explorer 8.