gpt4 book ai didi

c# - LINQ to XML .Count() 方法返回 HEX?如何将其转换为 Int?

转载 作者:太空宇宙 更新时间:2023-11-03 20:39:44 27 4
gpt4 key购买 nike

我在将值转换为 int 时遇到问题。

我运行这个查询来计算 xml 文件中的标签数量

 var items = (from category in xml.Descendants("category")
where category.Attribute("id").Value != "0"
select category).Count();

当我期望它返回 2 时,它返回了这个 0x00000002。我尝试使用 Convert.ToInt32 和 (int)variable 方法将它转换为 int,但它停留在 0x00000002。任何帮助将不胜感激。谢谢。

最佳答案

errrrr,十六进制不是数据类型,它只是查看整数的多种方式之一。

在你的调试器中,取消选择十六进制显示

(调试时右击变量)

关于c# - LINQ to XML .Count() 方法返回 HEX?如何将其转换为 Int?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3562723/

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