Object initializers


It has replaced the existing way of properties initialization with new approach. Below example shows the sample,

public class ProductUtility
{
  public int ProductId  {  get;set;    }
  public string ProductName { get;set; }
}
 
The new way of object initialization is,

ProductUtility pro=new ProductUtility(){ ProductId=101,ProductName ="Computer"};

This way we can easily create and initialize the object in c# 3.0.