开发者

IEnumerable to array of parameter

开发者 https://www.devze.com 2022-12-11 04:25 出处:网络
Using linq? and XML is there a way to convert this IEnumerable to a string array of the value parameter?

Using linq? and XML is there a way to convert this IEnumerable to a string array of the value parameter?

List<string> idList = new List<string>();
foreach (XElement idElement in word.Elements("id"))
{
    idList.Add(idElement.Value);
}
string[] ids = idList.ToArray();开发者_如何转开发

It would be similar to this

But I need the XElement.Value parameter

IEnumerable query = ...;
MyEntityType[] array = query.Cast<MyEntityType>().ToArray();


string[] ids = query.Select(x => x.Value).ToArray();


Use Select(x => x.Value).ToArray()

0

精彩评论

暂无评论...
验证码 换一张
取 消