Why is the compiler not complaining about an additional ',' in Array or Object Initializers?
- by Danvil
Using simple type like
class A {
public int X, Y;
}
with object intializers, one can write
var a = new A { X=0, Y=0 };
But the following is also accepted by the compiler:
var a = new A { X=0, Y=0, }; // notice the additional ','
Same for int[] v = new int[] { 1, 2, };
This looks a bit strange ... Did they forgot to reject the additional ',' in the compiler or is there a deeper meaning behind this?