Uri.IsBaseOf メソッドとは? わかりやすく解説

Uri.IsBaseOf メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

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

名前空間: System
アセンブリ: System (system.dll 内)
構文構文

解説解説

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

URI

http://host/path/path/file?query が次の URI のベースかどうか

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/

×

http://host/path/path2/MoreDir

×

http://host/path/File

×

使用例使用例

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

' 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
// 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);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

Uri.IsBaseOf メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Uri.IsBaseOf メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS