我正在尝试使用 LINQ to XML 对某些后代进行简单计数,但我不存在“Count()”方法?
例子:
using System.Xml.Linq;
XDocument doc = XDocument.Load( "somexmlfile" );
int count = doc.Descendants("somethinghere").Count();
以上不会编译,因为它不识别
Count()
方法。 最佳答案
文件顶部有 using System.Linq;
吗?