C#动态填充匿名类列表

时间:2019-06-27 11:13:39

标签: c# list

如果我具有列表的静态初始化:

var list = new[]
{
    new { Username = "Falcore", Score = 1293, },
    new { Username = "Dunsby", Score = 2342, },
    new { Username = "Habisham", Score = 5234, },
};

如何动态声明和填充这样的列表?即错误的伪代码:

var list = new[] {};

list.Add(new { Username = "Falcore", Score = 1293, });

0 个答案:

没有答案