The "C # 3.0 new features" are described earlier, and there is not much to be said about them, but in this way, a review of the new features of. NET 3.X.
Auto Property (Automatic properties)
It is useful to say that the property before the automatic property is a traditional attribute. Automatic properties simplify syntax, but also lose the ability to manipulate property settings when they are acquired, and to set initial values.
If you want to read-only or write-only, you can add an access modifier to a set or get, the access modifiers you set must be lower than the accessibility of the property itself, and you cannot set the access modifiers for both get and set; internal and protected intersect. Therefore, you cannot set properties and get or set separately for internal and protected.
The following code demonstrates automatic properties and traditional properties:
public class Test1
{
public int Int0 { get; set; }
public int Int1 { private get; set; }
private int int2;
private int int3;
public int Int2
{
get { return int2; }
set { int2 = value; }
}
public int Int3
{
get { return int3; }
}
}
After compiling, use ILDasm view as shown: