我在C#中写了一个LINQ
string etXML = File.ReadAllText("ET_Volume.xml"); string[] allLinesInAFile = etXML.Split('\n'); var possibleElements = from line in allLinesInAFile where !this.IsNode(line) select new { Node = line.Trim() }; string[] xmlLines = possibleElements.ToArray<string>();
问题出现在最后一行,出现以下错误:
System.Collections.Generic.IEnumerable<AnonymousType#1>
does
not contain a deFinition forToArray
and the best extension method
overload
System.Linq.Enumerable.ToArray<TSource>(System.Collections.Generic.IEnumerable<TSource>)
has some invalid argumentsInstance argument: cannot convert
fromSystem.Collections.Generic.IEnumerable<AnonymousType#1>
to
System.Collections.Generic.IEnumerable<string>
有什么问题以及将我的var转换为字符串[]的方法是什么?
解决方法
原文地址:https://www.jb51.cc/csharp/94666.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。