Created
April 22, 2017 14:19
-
-
Save einarwh/c783407fc2ea4671d9db4622b024c491 to your computer and use it in GitHub Desktop.
Object initializer surprise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var t = new Thing(new Thang { Thung = "lol" }) | |
{ | |
Thang = { Thung = "OMG" } | |
}; | |
t.Dump(); | |
} | |
class Thing | |
{ | |
private readonly Thang _thang; | |
public Thing(Thang thang) | |
{ | |
_thang = thang; | |
} | |
public Thang Thang | |
{ | |
get { return _thang; } | |
} | |
} | |
class Thang | |
{ | |
public string Thung { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment