I just noticed that in C # written in Visual Studio 2015, the following is possible: but I have never seen it before:
public class X { public int A { get; set; } public YB { get; set; } } public class Y { public int C {get; set; } } public void Foo() { var x = new X { A = 1, B = { C = 3 } }; }
My expectation was that Foo should be implemented as follows:
public void Foo() { var x = new X { A = 1, B = new Y { C = 3 } }; }
Note that there is no need to call new Y
Is this new in C # 6? I did not see mention of this in the notes, so maybe he was always there?
jonnystoten
source share