草庐IT

somethinghere

全部标签

c# - XDocument.Descendants ("somethinghere").Count() 方法不存在

我正在尝试使用LINQtoXML对一些后代进行简单计数并且“Count()”方法对我来说不存在?例子:usingSystem.Xml.Linq;XDocumentdoc=XDocument.Load("somexmlfile");intcount=doc.Descendants("somethinghere").Count();上面的代码不会编译,因为它不识别Count()方法。 最佳答案 文件顶部是否有usingSystem.Linq;? 关于c#-XDocument.Descenda