将列表匿名类型转换为列表字符串 [英] convert list anonymous type to list string
本文介绍了将列表匿名类型转换为列表字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
List<string> className = (from node in nodeList
where node.Attributes["class"] != null || !(string.IsNullOrEmpty(node.Attributes["class"].Value))
select new
{
classname = "." + node.Attributes["class"].Value.Trim().ToString()
}).ToList();
转换为List< string>
任何建议!
Plz help
its converting to a List<string>
any suggestion!
Plz help
推荐答案
不要创建匿名类型,只需选择一个字符串:< br $>
Do not create anonymous type, just select a string:
List<string> className = (from node in nodeList
where node.Attributes["class"] != null || !(string.IsNullOrEmpty(node.Attributes["class"].Value))
select ("." + node.Attributes["class"].Value.Trim())
).ToList();
List<string> className = (from node in nodeList
where node.Attributes["class"] != null || !(string.IsNullOrEmpty(node.Attributes["class"].Value))
select new
{
classname = "." + node.Attributes["class"].Value.Trim().ToString()
}).ToList<string>();
试试这个并告诉我它是否可以解决你的问题。
Try with this and let me know if it resolves your problem.
这篇关于将列表匿名类型转换为列表字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文