Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以从匿名类中定义数组或列表吗?
像这样:
persons = new ... [] { new { ID = 1, Name = "Name1"}, new { ID = 2, Name = "Name2"} }
是的,您只需要persons隐式键入变量并从数组创建语句中删除类型说明符。
persons
var persons = new [] { new { ID = 1, Name = "Name1" }, new { ID = 2, Name = "Name2" } }