XNamespace.Equality(XNamespace, XNamespace) 运算符

定义

返回一个值,该值指示 XNamespace 的两个实例是否相等。Returns a value indicating whether two instances of XNamespace are equal.

public:
 static bool operator ==(System::Xml::Linq::XNamespace ^ left, System::Xml::Linq::XNamespace ^ right);
public static bool operator == (System.Xml.Linq.XNamespace left, System.Xml.Linq.XNamespace right);
static member ( = ) : System.Xml.Linq.XNamespace * System.Xml.Linq.XNamespace -> bool
Public Shared Operator == (left As XNamespace, right As XNamespace) As Boolean

参数

left
XNamespace

要比较的第一个 XNamespaceThe first XNamespace to compare.

right
XNamespace

要比较的第二个 XNamespaceThe second XNamespace to compare.

返回

Boolean

指示 leftright 是否相等的 BooleanA Boolean that indicates whether left and right are equal.

示例

下面的示例演示 XNamespace 和字符串的比较。The following example shows the comparison of an XNamespace and a string.

XNamespace aw = "http://www.adventure-works.com";  
Console.WriteLine(aw == "http://www.adventure-works.com");  
Imports <xmlns="http://www.adventure-works.com">  
  
Module Module1  
    Sub Main()  
        Dim aw As XNamespace = GetXmlNamespace()  
        Console.WriteLine(aw = "http://www.adventure-works.com")  
    End Sub  
End Module  

此示例生成以下输出:This example produces the following output:

True  

注解

运算符重载 ==!=,用于启用 XNamespace 和字符串之间的比较(例如 element.Name.Namespace == "http://www.adventure-works.com")。The operator overloads == and != are provided to enable comparisons between XNamespace and string (for example, element.Name.Namespace == "http://www.adventure-works.com"). 中C#预定义的引用相等运算符要求一个操作数只能通过引用转换转换为另一个操作数,而不考虑从字符串到 XNamespace的隐式转换。The predefined reference equality operators in C# require one operand to be convertible to the type of the other through reference conversions only, and do not consider the implicit conversion from string to XNamespace.

适用于

另请参阅