Object Initialization Expressions

The object initialization expressions is another new C#3.0 feature. what is really cool about object initialization expressions is that they allow you to intialize new objects without calling the object constructor or set the properties. Below is an example of object initialization expressions.


public class Employee
{
    public int ID;
    public int Age;
    public int Salary;
    public string Name;
}

List employees = new List()
{
    new Employee(){ID=1,Age=27,Name = "John", Salary=3000},
    new Employee(){ID=1,Age=37,Name = "Sara", Salary=5000},
    new Employee(){ID=1,Age=31,Name = "Tommy", Salary=6000},
};