Cool in Visual Studio 2008 #3 - Automatic Properties
C# 3.0 comes with this new compiler feature called "automatic properties".
This is so useful (to reduce code written) that you wonder why nobody thought of this before.
Instead of this:
1: public class CurrencyOld
2: {
3: #region Members
4:
5: private string customerKey;
6: private string description;
7:
8: #endregion
9:
10: #region Properties
11:
12: public string CurrencyKey
13: {
14: get { return this.customerKey; }
15: set { this.customerKey = value; }
16: }
17:
18: public string Description
19: {
20: get { return this.description; }
21: set { this.description = value; }
22: }
23:
24: #endregion
25: }
You just need to write this (the members will be automatically "generated" for you by the compiler):
1: public class Currency
2: {
3: #region Properties
4:
5: public string CurrencyKey
6: {
7: get;
8: set;
9: }
10:
11: public string Description
12: {
13: get;
14: set;
15: }
16:
17: #endregion
18: }
Less 2 statements per property.