Uri.Equals(Object) メソッド

定義

2 つの Uri インスタンスを比較し、相互に等価かどうかを判断します。

public:
 override bool Equals(System::Object ^ comparand);
public override bool Equals (object comparand);
public override bool Equals (object? comparand);
override this.Equals : obj -> bool
Public Overrides Function Equals (comparand As Object) As Boolean

パラメーター

comparand
Object

現在のインスタンスと比較する URI または URI 識別子。

戻り値

Boolean

2 つのインスタンスが同じ URI を表す場合は true。それ以外の場合は false

この例では、文字列から 2 つの Uri インスタンスを作成し、それらを比較して、同じ値を表すかどうかを判断します。 address1 この address2 比較では部分が無視されるため Fragment 、同じです。 結果はコンソールに書き込まれます。

// Create some Uris.
Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" );
Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm" );
if ( address1->Equals( address2 ) )
{
   Console::WriteLine( "The two addresses are equal" );
}
else
{
   Console::WriteLine( "The two addresses are not equal" );
}
// Will output "The two addresses are equal"
// Create some Uris.
Uri address1 = new Uri("http://www.contoso.com/index.htm#search");
Uri address2 = new Uri("http://www.contoso.com/index.htm");
if (address1.Equals(address2))
    Console.WriteLine("The two addresses are equal");
else
    Console.WriteLine("The two addresses are not equal");
// Will output "The two addresses are equal"
// Create some Uris.
let address1 = Uri "http://www.contoso.com/index.htm#search"
let address2 = Uri "http://www.contoso.com/index.htm"
if address1.Equals address2 then
    printfn "The two addresses are equal"
else
    printfn "The two addresses are not equal"
// Will output "The two addresses are equal"
' 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")
If address1.Equals(address2) Then
    Console.WriteLine("The two addresses are equal")
Else
    Console.WriteLine("The two addresses are not equal")
End If
' Will output "The two addresses are equal"

注釈

このメソッドはEquals、含まれる可能性のあるユーザー情報 () とフラグメント (UserInfoFragment) 部分に関係なく、2 つのインスタンスを比較します。 たとえば、URI と http://www.contoso.com/index.htm#search http://user:password@www.contoso.com/index.htm、メソッドが Equals 返します true

1 つの Uri インスタンスが Unicode ホスト名で形成され、 comparand パラメーターに、同等の Punycode ホスト名を持つホスト名で構成されるインスタンスまたは識別子が含まれている Uri 場合は、 Equals 国際リソース識別子 (IRI) と国際化ドメイン名 (IDN) のサポートが有効になっている場合にのみ返 true されます。 Punycode 名には ASCII 文字のみが含まれ、常に xn-- プレフィックスで始まります。

IRI サポートの詳細については、クラスの「解説」セクションを Uri 参照してください。

注意

.NET Framework バージョン 1.0 および 1.1 では、これもQuery無視されます。

注意

メソッドは Equals 派生クラスでオーバーライドできます。悪意のあるエンティティがメソッドを変更する可能性がある場合は注意が必要です。 このインスタンスが信頼できるソースから取得されたことがわかっている場合を除き、このメソッドを使用してセキュリティ チェックを実行しないでください。

適用対象