Auto Properties in C# 6.0

There are lot of new and exciting features added introduced in C#6.0 lets discuss new feature ‘auto properties

In earlier version, our declaration was:

public int RollNumber {get;set;}

In above we need to do something like this classname.property name to get / set the values.

Now you can imagine in C#6.0 we can directly set values like:

int _rollNumber = 123456;  
public int RollNumber {get;set;} = _rollNumber;

And here is the ReadOnly Property

public int RollNumber {get;} = _rollNumber;  

Enjoy the flavor of new features by using Visual Studio2015 preview 🙂

Leave A Reply