假设IEnumerable数据为
IEnumerable values=[
{"EM_NAME":"Abu Dhabi"},
{"EM_NAME":"Ajman"},
{"EM_NAME":"Dubai"},
{"EM_NAME":"Fujairah"},
{"EM_NAME":"Ras al Khaimah"},
{"EM_NAME":"Sharjah"},
{"EM_NAME":"Umm al Quwain"}
]
有没有办法在不使用循环
的情况下获得这样的数组array=[
"Abu Dhabi",
"Ajman",
"Dubai",
"Fujairah",
"Ras al Khaimah",
"Sharjah",
"Umm al Quwain"
]
编辑:尝试过ToArray()
答案 0 :(得分:2)
MyEntityType[] array = values.Cast<MyEntityType>().ToArray();
答案 1 :(得分:0)
只需使用IEnumerable.ToArray()
values.ToArray() in your case
答案 2 :(得分:0)
使用静态Enumerable.ToArray
方法。
http://msdn.microsoft.com/en-us/library/bb298736(v=vs.110).aspx