The Infinite Loop – Beginner's SEO, Beginner C# & JQuery Tutorials Problem. Problem Solved. Loop. – The life of a programmer

17Aug/110

Automatic Get/Set Visual C# 2010

One of my favorite features of c#. Automatic getters/setters!

Before, one would have to declare a variable.

private int _x;
And then write get/set methods:

public int X{
get{return _x;}
set{x=value;}
}

However, in VISUAL C# 2010 - you can now do the following:
public int X{get;set;} Which is the same as the code above!

Note: If you want to wrap any validation or anything around the get/set you will still need to write out the full get/set. However, for quick variables that require no extra work - the automatic get/set is a lifesaver! (or timesaver - if you're life is not in danger...whichever you prefer)

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Buzz
Filed under: C#, General Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.