I have the following object being created:
var i = 0;
var foo = new Foo();
foo.A = ++i;
foo.B = ++i;
foo.C = ++i;
Assert(foo.A == 1);
Assert(foo.B == 2);
Assert(foo.C == 3);
The same object can we written using an object initializer:
var i = 0;
var foo = new Foo
{
A = ++i,
B = ++i,
C = ++i
}
Assert(foo.A == 1);
Assert(foo.B == 2);
Assert(foo.C == 3);
Is the order that the properties are set guaranteed in the case of the object initializer?