gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 02:00:51 30 4
gpt4 key购买 nike

我正在尝试使用 LINQ to XML 对一些后代进行简单计数并且“Count()”方法对我来说不存在?

例子:

using System.Xml.Linq;

XDocument doc = XDocument.Load( "somexmlfile" );
int count = doc.Descendants("somethinghere").Count();

上面的代码不会编译,因为它不识别 Count() 方法。

最佳答案

文件顶部是否有 using System.Linq;

关于c# - XDocument.Descendants ("somethinghere").Count() 方法不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6238936/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com