XName.Equality(XName, XName) 操作员
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回一个值,该值指示两个实例 XName 是否相等。
public:
static bool operator ==(System::Xml::Linq::XName ^ left, System::Xml::Linq::XName ^ right);
public static bool operator ==(System.Xml.Linq.XName left, System.Xml.Linq.XName right);
public static bool operator ==(System.Xml.Linq.XName? left, System.Xml.Linq.XName? right);
static member ( = ) : System.Xml.Linq.XName * System.Xml.Linq.XName -> bool
Public Shared Operator == (left As XName, right As XName) As Boolean
参数
返回
true 如果 left 且 right 相等,则为 ;否则 false为 。
示例
以下示例显示了对象和字符串之间的 XName 一些比较。
XName xn;
xn = XName.Get("Root");
Console.WriteLine(xn == "Root");
xn = XName.Get("Root", "http://www.adventure-works.com");
Console.WriteLine(xn == "{http://www.adventure-works.com}Root");
XElement root = new XElement("Root", "content");
Console.WriteLine(root.Name == "Root");
Dim xn As XName
xn = XName.Get("Root")
Console.WriteLine(xn = "Root")
xn = XName.Get("Root", "http://www.adventure-works.com")
Console.WriteLine(xn = "{http://www.adventure-works.com}Root")
Dim root As XElement = New XElement("Root", "content")
Console.WriteLine(root.Name = "Root")
此示例生成以下输出:
True
True
True
注解
运算符重载 == 并 != 包含在内,用于启用与 XName a string之间的比较,例如element.Name == "SomeElementName"。 C# 中的预定义引用相等运算符需要一个操作数才能通过引用转换转换为另一个操作数的类型。 这些运算符不考虑从字符串到 XName..