1
添加项目,我需要做的是恢复活力[]如何在动态数组
这对我
public static dynamic[] GetDonutSeries(this Polls p)
{
return new dynamic[]
{
new {category = "Football",value = 35},
new {category = "Basketball",value = 25},
new {category = "Volleyball",value = 20},
new {category = "Rugby",value = 10},
new {category = "Tennis",value = 10}
};
}
工作正常功能,但我需要补充的项目做不同的操作。
像这样
public static dynamic[] GetDonutSeries(this Polls p)
{
dynamic[] result = new dynamic[]();
foreach (PollOptions po in p.PollOptions)
{
result.Add(new {category = po.OptionName,value = po.PollVotes.Count});
}
return result;
}
,但我不能使用动态[]。新增方法。我如何做到这一点?
是否'动态[]结果=新的动态[]();'编译所有? – Rahul
是的,它编译 – Turi