Uri.GetLeftPart(UriPartial) Uri.GetLeftPart(UriPartial) Uri.GetLeftPart(UriPartial) Uri.GetLeftPart(UriPartial) Method

定義

Uri インスタンスの指定部分を取得します。Gets the specified portion of a Uri instance.

public:
 System::String ^ GetLeftPart(UriPartial part);
public string GetLeftPart (UriPartial part);
member this.GetLeftPart : UriPartial -> string
Public Function GetLeftPart (part As UriPartial) As String

パラメーター

part
UriPartial UriPartial UriPartial UriPartial

UriPartial 値のうち、返される URI 部分の末尾を指定する値。One of the UriPartial values that specifies the end of the URI portion to return.

戻り値

String インスタンスの指定部分を含む UriA String that contains the specified portion of the Uri instance.

例外

現在の Uri インスタンスは、絶対インスタンスではありません。The current Uri instance is not an absolute instance.

指定した part が有効ではありません。The specified part is not valid.

次の例では、作成、Uriインスタンスし、パスをコンソールに書き込みます。The following example creates a Uri instance and writes the path to the console.

// Create Uri
Uri^ uriAddress = gcnew Uri( "http://www.contoso.com/index.htm#search" );
Console::WriteLine( uriAddress->Fragment );
Console::WriteLine( "Uri {0} the default port ", uriAddress->IsDefaultPort ? (String^)"uses" : "does not use" );

Console::WriteLine( "The path of this Uri is {0}", uriAddress->GetLeftPart( UriPartial::Path ) );
Console::WriteLine( "Hash code {0}", uriAddress->GetHashCode() );
// The example displays the following output:
//        #search
//        Uri uses the default port
//        The path of this Uri is http://www.contoso.com/index.htm
//        Hash code -988419291
// 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());
// The example displays the following output:
//        #search
//        Uri uses the default port
//        The path of this Uri is http://www.contoso.com/index.htm
//        Hash code -988419291
' 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 ", If(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())
' The example displays the following output:
'        #search
'        Uri uses the default port
'        The path of this Uri is http://www.contoso.com/index.htm
'        Hash code -988419291

注釈

GetLeftPartメソッドで指定された部分で終わる、URI 文字列の左端の部分を含む文字列を返しますpartします。The GetLeftPart method returns a string containing the leftmost portion of the URI string, ending with the portion specified by part.

GetLeftPart 次のような場合は、区切り記号が含まれています。GetLeftPart includes delimiters in the following cases:

  • Scheme スキームの区切り記号が含まれています。Scheme includes the scheme delimiter.

  • Authority パスの区切り記号は含まれません。Authority does not include the path delimiter.

  • Path クエリやフラグメントの区切り記号までの元の URI では、任意の区切り記号が含まれています。Path includes any delimiters in the original URI up to the query or fragment delimiter.

  • Query 含まれています、 Path、さらに、クエリとその区切り記号。Query includes the Path, plus the query and its delimiter.

次の例では、URI と、呼び出しの結果を表示するGetLeftPartSchemeAuthorityPath、またはQueryします。The following examples show a URI and the results of calling GetLeftPart with Scheme, Authority, Path, or Query.

URIURI SchemeScheme 機関Authority パスPath クエリQuery
http://www.contoso.com/index.htm?date=today http://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:// http://www.contoso.com http://www.contoso.com/index.htm http://www.contoso.com/index.htm
mailto:user@contoso.com?subject=urimailto:user@contoso.com?subject=uri mailto:mailto: mailto:user@contoso.com mailto:user@contoso.com?subject=urimailto:user@contoso.com?subject=uri <none><none>
nntp://news.contoso.com/123456@contoso.com nntp://nntp:// nntp://news.contoso.comnntp://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 <none><none>
file://server/filename.extfile://server/filename.ext file://file:// file://serverfile://server file://server/filename.extfile://server/filename.ext file://server/filename.extfile://server/filename.ext

適用対象