Uri.Equality(Uri, Uri) Operador

Definição

Determina se duas instâncias Uri têm o mesmo valor.Determines whether two Uri instances have the same value.

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

Parâmetros

uri1
Uri

Um URI para comparar com uri2.A URI to compare with uri2.

uri2
Uri

Um URI para comparar com uri1.A URI to compare with uri1.

Retornos

Boolean

true se as Uri instâncias forem equivalentes; caso contrário, false.true if the Uri instances are equivalent; otherwise, false.

Exemplos

Este exemplo cria três Uri instâncias de cadeias de caracteres e as compara para determinar se elas representam o mesmo valor.This example creates three Uri instances from strings and compares them to determine whether they represent the same value. Address1 e Address2 são os mesmos porque a Fragment parte é ignorada para essa comparação.Address1 and Address2 are the same because the Fragment portion is ignored for this comparison. O resultado é gravado no console.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

Comentários

Essa sobrecarga usa o Equals método para determinar se as duas Uri instâncias são equivalentes.This overload uses the Equals method to determine whether the two Uri instances are equivalent. UserInfo e Fragment o conteúdo é ignorado ao fazer essa comparação.UserInfo and Fragment content is ignored when making this comparison.

Aplica-se a