Saturday, August 15, 2015

C# 6.0 latest Featues


Auto Property Initializer: In this we can intilize our properties at the time of declaration>it is just like a field declaration.

Public class User
{
public string Fname{get;set;}="Akash"
public string  Lname{get;}="Ramesh"
}


Primary Constructor:

public user(string FName,string LName)
{
public string Fname{get;set;}=Fname

}

Exception Filters:-
try
{
throw new Exception("Hello")
}
Catch(Exception ex) if(ex.Message=="Hello")
{
//It will run

}
Catch(Exception ex1) if(ex.Message=="Hi")
{
//Not Run

}

Index Initializes or Dictionary Initializer:
var num=new Dictionary<int,string>
{
[1]="one",
[2]="two"
};

No comments:

Post a Comment