Quantcast
Channel: Gaurav-Arora.com » Code-Snippets
Viewing all articles
Browse latest Browse all 8

Auto Properties in C# 6.0

$
0
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 :)

The post Auto Properties in C# 6.0 appeared first on Gaurav-Arora.com.


Viewing all articles
Browse latest Browse all 8

Trending Articles