Uri.Equals メソッド

定義

オーバーロード

Equals(Object)

2 つの Uri インスタンスを等しいかどうかを比較します。

Equals(Uri)

2 つの Uri インスタンスを等しいかどうかを比較します。

Equals(Object)

ソース:
Uri.cs
ソース:
Uri.cs
ソース:
Uri.cs

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 識別子。

戻り値

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

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

// 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 メソッドは、ユーザー情報 (UserInfo) とフラグメント (Fragment) 部分に関係なく、2 つのインスタンスを比較します。 たとえば、URI の http://www.contoso.com/index.htm#searchhttp://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 メソッドは派生クラスでオーバーライドできます。悪意のあるエンティティがメソッドを変更する可能性がある場合は注意が必要です。 このインスタンスが信頼できるソースから取得されたことがわかっている場合を除き、このメソッドを使用してセキュリティ チェックを実行しないでください。

適用対象

Equals(Uri)

2 つの Uri インスタンスを等しいかどうかを比較します。

public:
 virtual bool Equals(Uri ^ other);
public bool Equals (Uri? other);
override this.Equals : Uri -> bool
Public Function Equals (other As Uri) As Boolean

パラメーター

other
Uri

このインスタンスと比較する Uri

戻り値

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

実装

適用対象