C#和匿名对象数组 [英] C# and arrays of anonymous objects
本文介绍了C#和匿名对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这样的表达是什么意思?
What does such an expression mean?
obj.DataSource = new[]
{
new {Text = "Silverlight", Count = 10, Link="/Tags/Silverlight" },
new {Text = "IIS 7", Count = 11, Link="http://iis.net" },
new {Text = "IE 8", Count = 12, Link="/Tags/IE8" },
new {Text = "C#", Count = 13, Link="/Tags/C#" },
new {Text = "Azure", Count = 13, Link="?Tag=Azure" }
};
尤其是以下几行:new {Text ="IIS 7" ...}
Especially these lines: new {Text = "IIS 7"... }
如何手动创建类似于此数据源的数组.
How can I create an array like this manually to suit this DataSource.
推荐答案
那不是多维数组.这是使用具有匿名类型的对象初始化程序创建的对象数组
That's not a multidimensional array. That's an array of objects which have been created using object initializers with anonymous types.
这篇关于C#和匿名对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文