Uri.Equality(Uri, Uri) Operator
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Bestimmt, ob zwei Uri-Instanzen denselben Wert haben.
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
Parameter
- uri1
- Uri
Ein URI, der mit uri2
verglichen werden soll.
- uri2
- Uri
Ein URI, der mit uri1
verglichen werden soll.
Gibt zurück
true
, wenn die Uri-Instanzen äquivalent sind, andernfalls false
.
Beispiele
In diesem Beispiel werden drei Uri Instanzen aus Zeichenfolgen erstellt und verglichen, um zu bestimmen, ob sie denselben Wert darstellen.
Address1
und Address2
sind identisch, da der Fragment Teil für diesen Vergleich ignoriert wird. Das Ergebnis wird in die Konsole geschrieben.
// 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.
let address1 = Uri "http://www.contoso.com/index.htm#search"
let address2 = Uri "http://www.contoso.com/index.htm"
let address3 = Uri "http://www.contoso.com/index.htm?date=today"
// The first two are equal because the fragment is ignored.
if address1 = address2 then
printfn $"{address1} is equal to {address2}"
// The second two are not equal.
if address2 <> address3 then
printfn $"{address2} is not equal to {address3}"
' 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
Hinweise
Diese Überladung verwendet die Equals -Methode, um zu bestimmen, ob die beiden Uri Instanzen gleichwertig sind. UserInfo und Fragment Inhalte werden bei diesem Vergleich ignoriert.