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

반환할 URI 부분의 끝을 지정하는 UriPartial 값 중 하나입니다.One of the UriPartial values that specifies the end of the URI portion to return.

반환

지정된 String 인스턴스 부분을 포함하는 Uri입니다.A 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 및 호출의 결과 보여 GetLeftPart 사용 하 여 Scheme, Authority합니다 Path, 또는 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://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 <none>
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 <none>
file://server/filename.ext file:// file://server file://server/filename.ext file://server/filename.ext

적용 대상