- Automatic Property setters/getters
- Object Initializers
- Collection Initializers
- Implicitly Typed Variable
- Extension Methods
- Anonymous Types
public class Employee
{
private int _id;
private string _name;
public int Id{get{ return _id; }set{ _id=value;}}
public string Name{get{return _name;}set{_name=value;}}
}
Changed to
public class Employee
{
public int Id{get;set;}
public string Name{get;set;}
}
No need of local variable
Object Initializers
Employee emp=new Employee{
Id=1,Name="Tech Update"
Location =new Country{ CountryId=11,Name="India" }
}
Collection Initializers
List<Employee> lst= List<Employee>
{
new Employee{Id = 101, Name = "Foo"},
new Employee{Id = 102,Name = "Goo"},
new Employee{Id = 103,Name = "Hoo"}
};
Extension methods are a new feature that allows you to enhance an existing class by adding a new method to it without modifying the actual code for the class.
Will Update this in Linq section