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

Uri.GetLeftPart メソッド

Uri インスタンスの指定部分を返します。

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

Public Function GetLeftPart ( _
    part As UriPartial _
) As String
Dim instance As Uri
Dim part As UriPartial
Dim returnValue As String

returnValue = instance.GetLeftPart(part)
public string GetLeftPart (
    UriPartial part
)
public:
String^ GetLeftPart (
    UriPartial part
)
public String GetLeftPart (
    UriPartial part
)
public function GetLeftPart (
    part : UriPartial
) : String

パラメータ

part

UriPartial 値のうち、返される URI 部分の末尾を指定する値。

戻り値
Uri インスタンスの指定部分を含む String。

例外例外
例外の種類条件

InvalidOperationException

現在の Uri インスタンスは、絶対インスタンスではありません。

ArgumentException

指定した part が有効ではありません。

解説解説

GetLeftPart メソッドは、URI 文字列の左端から part により指定された位置までの部分を格納した文字列を返します。

GetLeftPart が返す文字列に区切り記号が含まれる状況を次に示します。

次に示す例は、Scheme、Authority、Path、または Query を指定して GetLeftPart を呼び出した結果と URI を示しています。

URI

Scheme

Authority

Path

Query

http://www.contoso.com/index.htm?date=today

http://

http://www.contoso.com

http://www.contoso.com/index.htm

http://www.contoso.com/index.htm?date=today

http://www.contoso.com/index.htm#main

http://

http://www.contoso.com

http://www.contoso.com/index.htm

http://www.contoso.com/index.htm

mailto:user@contoso.com?subject=uri

mailto:

mailto:user@contoso.com

mailto:user@contoso.com?subject=uri

なし

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:123456@contoso.com

news:

news:123456@contoso.com

news:123456@contoso.com

なし

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



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「Uri.GetLeftPart メソッド」の関連用語

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

   

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



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

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

©2026 GRAS Group, Inc.RSS