XName.Inequality(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 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
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
.NET