XName.Equality(XName, 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
参数
返回
如果 left 和 right 相等,则为 true;否则为 false。true if left and right are equal; otherwise false.
示例
下面的示例演示了 XName 对象和字符串之间的一些比较。The following example shows some comparisons between XName objects and strings.
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")
该示例产生下面的输出:This example produces the following output:
True
True
True
注解
包含运算符重载 == 和 != 以启用与之间的比较 XName string ,如 element.Name == "SomeElementName" 。The operator overloads == and != are included to enable comparisons between XName and a string, such aselement.Name == "SomeElementName". C # 中预定义的引用相等运算符要求一个操作数只能通过引用转换转换为另一个操作数。The predefined reference equality operators in C# require one operand to be convertible to the type of the other through reference conversions only. 这些运算符不考虑从字符串到的隐式转换 XName 。These operators do not consider the implicit conversion from string to XName.