Szerkesztés

Megosztás a következőn keresztül:


XName.Inequality(XName, XName) Operator

Definition

Returns a value indicating whether two instances of XName are not 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 op_Inequality : 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 not equal; otherwise false.

Examples

The following C# example compares an XName object to a string, which invokes this operator.

XNamespace aw = "http://www.adventure-works.com";
XElement root = new XElement(aw + "Root", "content");

Console.WriteLine(root.Name != "{http://www.adventure-works.com}Root");

// the following is the preferred idiom
Console.WriteLine(root.Name != aw + "Root");
Imports <xmlns="http://www.adventure-works.com">

Module Module1
    Sub Main()
        Dim root As XElement = <Root>content</Root>
        Console.WriteLine(root.Name <> "{http://www.adventure-works.com}Root")

        ' the following is the preferred idiom
        Console.WriteLine(root.Name <> GetXmlNamespace() + "Root")
    End Sub
End Module

This example produces the following output:

False
False

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