Uri.GetLeftPart(UriPartial) 메서드

정의

지정된 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

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

반환

String

Uri 인스턴스의 지정된 부분입니다.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 output similar to the following:
//        #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 output similar to the following:
//        #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 output similar to the following:
'        #search
'        Uri uses the default port
'        The path of this Uri is http://www.contoso.com/index.htm
'        Hash code -988419291

설명

The <xref:System.Uri.GetLeftPart%2A> 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 AuthorityAuthority 경로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

적용 대상