Breyta

Deila með


XName.Equality(XName, XName) Operator

Definition

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

left
XName

The first XName to compare.

right
XName

The second XName to compare.

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.

Applies to

See also