Reputation: 1909
Consider this
var source = new{ Id = "1", Name = "Name1"}
It works fine. But if I want to add 1 more property how to do so...
It failed
var source = new{ Id = "1", Name = "Name1"},new{ Id = "1", Name = "Name1"}
what is the correct syntax for this?
Upvotes: 3
Views: 223
Reputation: 499352
See Collection initializers and anonymous types on MSDN:
var source = new [] { new { Id = "1", Name = "Name1"},
new { Id = "2", Name = "Name2"}};
Upvotes: 7