Uri.GetLeftPart メソッド
アセンブリ: System (system.dll 内)
構文
Dim instance As Uri Dim part As UriPartial Dim returnValue As String returnValue = instance.GetLeftPart(part)
戻り値
Uri インスタンスの指定部分を含む String。
GetLeftPart メソッドは、URI 文字列の左端から part により指定された位置までの部分を格納した文字列を返します。
GetLeftPart が返す文字列に区切り記号が含まれる状況を次に示します。
次に示す例は、Scheme、Authority、Path、または Query を指定して GetLeftPart を呼び出した結果と URI を示しています。
http://www.contoso.com | http://www.contoso.com/index.htm | |||
http://www.contoso.com | http://www.contoso.com/index.htm | http://www.contoso.com/index.htm | ||
なし | ||||
nntp://news.contoso.com/123456@contoso.com | nntp:// | nntp://news.contoso.com | nntp://news.contoso.com/123456@contoso.com | nntp://news.contoso.com/123456@contoso.com |
news: | なし | |||
file://server/filename.ext | file:// | file://server | file://server/filename.ext | file://server/filename.ext |
Uri インスタンスを作成し、パスをコンソールに出力する例を次に示します。
' Create Uri Dim uriAddress As New Uri("http://www.contoso.com/index.htm#search") Console.WriteLine(uriAddress.Fragment) Console.WriteLine("Uri {0} the default port ", IIf(uriAddress.IsDefaultPort, "uses", "does not use")) 'TODO: For performance reasons this should be changed to nested IF statements Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path)) Console.WriteLine("Hash code {0}", uriAddress.GetHashCode())
// Create Uri Uri uriAddress = new Uri("http://www.contoso.com/index.htm#search"); Console.WriteLine(uriAddress.Fragment); Console.WriteLine("Uri {0} the default port ", uriAddress.IsDefaultPort ? "uses" : "does not use"); Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path)); Console.WriteLine("Hash code {0}", uriAddress.GetHashCode());
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- Uri.GetLeftPart メソッドのページへのリンク