Uri.Inequality(Uri, Uri) Uri.Inequality(Uri, Uri) Uri.Inequality(Uri, Uri) Uri.Inequality(Uri, Uri) Operator

定义

确定两个 Uri 实例是否具有不同的值。Determines whether two Uri instances do not have the same value.

public:
 static bool operator !=(Uri ^ uri1, Uri ^ uri2);
public static bool operator != (Uri uri1, Uri uri2);
static member op_Inequality : Uri * Uri -> bool
Public Shared Operator != (uri1 As Uri, uri2 As Uri) As Boolean

参数

uri1
Uri Uri Uri Uri

要与 Uri 比较的 uri2 实例。A Uri instance to compare with uri2.

uri2
Uri Uri Uri Uri

要与 Uri 比较的 uri1 实例。A Uri instance to compare with uri1.

返回

一个 Boolean 值。如果两个 true 实例不相等,则该值为 Uri;否则为 falseA Boolean value that is true if the two Uri instances are not equal; otherwise, false. 如果两者中任意一个参数为 null,则此方法返回 trueIf either parameter is null, this method returns true.

示例

此示例创建三个Uri实例从字符串并将它们,以确定它们是否表示相同的值进行比较。This example creates three Uri instances from strings and compares them to determine whether they represent the same value. Address2Address3是不相同,因为Address3包含Query中未找到Address2Address2 and Address3 are not the same because Address3 contains a Query that is not found in Address2. 结果将写入控制台。The outcome is written to the console.

// Create some Uris.
Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" );
Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm" );
Uri^ address3 = gcnew Uri( "http://www.contoso.com/index.htm?date=today" );

// The first two are equal because the fragment is ignored.
if ( address1 == address2 )
   Console::WriteLine( "{0} is equal to {1}", address1, address2 );

// The second two are not equal.
if ( address2 != address3 )
   Console::WriteLine( "{0} is not equal to {1}", address2, address3 );
// Create some Uris.
Uri address1 = new Uri("http://www.contoso.com/index.htm#search");
Uri address2 = new Uri("http://www.contoso.com/index.htm"); 
Uri address3 = new Uri("http://www.contoso.com/index.htm?date=today"); 

// The first two are equal because the fragment is ignored.
if (address1 == address2)
    Console.WriteLine("{0} is equal to {1}", address1.ToString(), address2.ToString());

// The second two are not equal.
if (address2 != address3)
    Console.WriteLine("{0} is not equal to {1}", address2.ToString(), address3.ToString());
' Create some Uris.
Dim address1 As New Uri("http://www.contoso.com/index.htm#search")
Dim address2 As New Uri("http://www.contoso.com/index.htm")
Dim address3 As New Uri("http://www.contoso.com/index.htm?date=today")

' The first two are equal because the fragment is ignored.
If address1 = address2 Then
    Console.WriteLine("{0} is equal to {1}", address1.ToString(), address2.ToString())
End If 
' The second two are not equal.
If address2 <> address3 Then
    Console.WriteLine("{0} is not equal to {1}", address2.ToString(), address3.ToString())
End If

注解

此重载使用Equals方法,以确定是否两个Uri实例是否不相等。This overload uses the Equals method to determine whether the two Uri instances are not equivalent. UserInfoFragment内容进行这种比较时被忽略。UserInfo and Fragment content is ignored when making this comparison.

适用于