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。

戻り値

Boolean

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

例外

urinullです。

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

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

// Create a new Uri from a string.
Uri^ uriAddress = gcnew 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.
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 の底になります。最後のスラッシュ (/) の後の uri2 内のすべてを無視すると、2 つの URI が同じになります。 ベース 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 no
http://host/path/path?query no
http://host/path/path#Fragment no
http://host/path/path2/
://host/path/path2/MoreDir
http://host/path/File

適用対象