Reputation: 36610
I want to create anonymous object in C#, and some its child is also object. Is it possible to do that in C#? (PS. I got some hint error for the following code)
var o = new { age = 123, child = { name = "asdffff"} };
Upvotes: 0
Views: 185
Reputation: 1378
You're missing the 'new':
var o = new { age = 123, child = new { name = "asdffff"} };
Upvotes: 2