【发布时间】:2011-06-04 19:35:36
【问题描述】:
我正在尝试使用LINQ to XML 对一些后代进行简单计数,但我不存在“Count()”方法吗?
例子:
using System.Xml.Linq;
XDocument doc = XDocument.Load( "somexmlfile" );
int count = doc.Descendants("somethinghere").Count();
上面的代码无法编译,因为它无法识别Count() 方法。
【问题讨论】:
-
文件顶部有
using System.Linq;吗? -
不,这解决了它!你的男人!