XName.Equality(XName, XName) Operator
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a value indicating whether two instances of XName are equal.
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
Parameters
Returns
true
if left
and right
are equal; otherwise false
.
Examples
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
Remarks
The operator overloads ==
and !=
are included to enable comparisons between XName and a string
, such aselement.Name == "SomeElementName"
. The predefined reference equality operators in C# require one operand to be convertible to the type of the other through reference conversions only. These operators do not consider the implicit conversion from string to XName.