C# : automatic properties

4/1/2014·1 min read

you can use as following, also when you type, you can type prop + tab. Than visual studio code snippet will automatic create syntax for you.

how to use it
public int Id { get; set; }

If you use .net reflector to take a look for the property, it displayed following code.

what's it looks like in .net
[CompilerGenerated]
public void set_Id(int value)
{
 this.<Id> k__BackingField = value;
}
[CompilerGenerated]
public int get_Id()
{
return this.<Id>k__BackingField;
}
[CompilerGenerated]
private int<Id> k__BackingField;