在VB.NET
中,我使用以下命令来获取标记值:
Dim endval = cint(googleXMLdocument...<s:currentItemCount>.Value) - 1
如何在C#
中执行此操作
我尝试了以下方法,但它有一个语法错误
var endval = (short)googleXMLDoc...<s:currentItemCount>.Value) - 1;
C#
部件有什么问题?
发布于 2013-03-02 20:43:29
以下是VB.NET上快捷键图例:http://msdn.microsoft.com/en-us/library/bb384974.aspx
没有C#等效项,因此您必须使用标准的LINQ to XML方法:
.<name> .Elements("name")
...<name> .Descendants("name")
.Value .First()
.@name .Attribute("name")
关于你的例子-你应该在C#中尝试一下:
var endval = (short)googleXmlDoc.Descendants("currentItemCount").First() - 1;
但是,如果您向我们展示示例XML和预期结果,就会容易得多。
https://stackoverflow.com/questions/15179012
复制相似问题