Possible Duplicate:
What's the difference between an object initializer and a constructor?
In c# you can construct an object like:
public class MyObject{
int val1;
int val2;
public MyObject(int val1, val2){
this.val1 = val1;
this.val2 = val2;
}
}
With:
MyObject ob = new MyObject(1,2);
or with:
MyObject ob = new MyObject(){ val1 = 1, val2 = 2 };
What is the diference between that kind of constructors?