Uri.IsBaseOf(Uri) メソッド

定義

現在の Uri インスタンスが、指定した Uri インスタンスのベースであるかどうかを判断します。

public:
 bool IsBaseOf(Uri ^ uri);
public bool IsBaseOf(Uri uri);
member this.IsBaseOf : Uri -> bool
Public Function IsBaseOf (uri As Uri) As Boolean

パラメーター

uri
Uri

テストする指定された URI。

返品

true 現在の Uri インスタンスが uriのベースである場合は。それ以外の場合は false

例外

urinullです。

この例では、ベース Uri インスタンスを表すUri インスタンスを作成します。 次に、文字列から 2 つ目の Uri インスタンスを作成します。 IsBaseOfを呼び出して、基本インスタンスが 2 番目のインスタンスのベースであるかどうかを判断します。 結果はコンソールに書き込まれます。

// Create a base Uri.
Uri baseUri = new Uri("http://www.contoso.com/");

// Create a new Uri from a string.
Uri uriAddress = new Uri("http://www.contoso.com/index.htm?date=today");

// Determine whether BaseUri is a base of UriAddress.
if (baseUri.IsBaseOf(uriAddress))
    Console.WriteLine("{0} is the base of {1}", baseUri, uriAddress);
// Create a base Uri.
let baseUri = Uri "http://www.contoso.com/"

// Create a new Uri from a string.
let uriAddress = Uri "http://www.contoso.com/index.htm?date=today"

// Determine whether BaseUri is a base of UriAddress.
if baseUri.IsBaseOf uriAddress then
    printfn $"{baseUri} is the base of {uriAddress}"
' Create a base Uri.
Dim baseUri As New Uri("http://www.contoso.com/")

' Create a new Uri from a string.
Dim uriAddress As New Uri("http://www.contoso.com/index.htm?date=today")

' Determine whether BaseUri is a base of UriAddress.  
If baseUri.IsBaseOf(uriAddress) Then
    Console.WriteLine("{0} is the base of {1}", baseUri, uriAddress)
End If

注釈

IsBaseOf は、現在の Uri インスタンスを指定した Uri と比較して、この URI が指定された Uriのベースであるかどうかを判断するために使用されます。 2 つの Uri オブジェクトを比較して基本リレーションシップを決定する場合、ユーザー情報 (UserInfo) は評価されません。 2 つの URI (uri1 と uri2) を比較する場合、uri1 は uri2 の基になります。最後のスラッシュ (/) の後に uri1 と uri2 のすべてを無視すると、uri2 は uri1 で始まります。 ベース URI として http://host/path/path/file?query を使用して、それが他の URI のベースであるかどうかを次の表に示します。

URI http://host/path/path/file?query は次のベースです。
http://host/path/path/file/ はい
http://host/path/path/#fragment はい
http://host/path/path/MoreDir/" はい
http://host/path/path/OtherFile?Query はい
http://host/path/path/ はい
http://host/path/path/file はい
http://host/path/path いいえ
http://host/path/path?query いいえ
http://host/path/path#Fragment いいえ
http://host/path/path2/ いいえ
://host/path/path2/MoreDir いいえ
http://host/path/File いいえ

適用対象