Uri.Segments 속성

정의

지정된 URI를 구성하는 경로 세그먼트가 포함된 배열을 가져옵니다.

public:
 property cli::array <System::String ^> ^ Segments { cli::array <System::String ^> ^ get(); };
public string[] Segments { get; }
member this.Segments : string[]
Public ReadOnly Property Segments As String()

속성 값

String[]

지정된 URI를 구성하는 경로 세그먼트입니다.

예외

이 인스턴스가 상대 URI를 나타내고 이 속성이 절대 URI에만 유효한 경우

예제

다음 예제에서는 세그먼트가 3개인 인스턴스를 만들고 Uri 화면에 세그먼트를 표시합니다.

Uri^ uriAddress1 = gcnew Uri( "http://www.contoso.com/title/index.htm" );
Console::WriteLine( "The parts are {0}, {1}, {2}", uriAddress1->Segments[ 0 ], uriAddress1->Segments[ 1 ], uriAddress1->Segments[ 2 ] );
Uri uriAddress1 = new Uri("http://www.contoso.com/title/index.htm");
Console.WriteLine("The parts are {0}, {1}, {2}", uriAddress1.Segments[0], uriAddress1.Segments[1], uriAddress1.Segments[2]);
let uriAddress1 = Uri "http://www.contoso.com/title/index.htm"
printfn $"The parts are {uriAddress1.Segments[0]}, {uriAddress1.Segments[1]}, {uriAddress1.Segments[2]}"
Dim uriAddress1 As New Uri("http://www.contoso.com/title/index.htm")
Console.WriteLine("The parts are {0}, {1}, {2}", uriAddress1.Segments(0), uriAddress1.Segments(1), uriAddress1.Segments(2))

설명

이 속성은 Segments URI의 절대 경로를 형성하는 "segments"(부분 문자열)를 포함하는 문자열 배열을 반환합니다. 첫 번째 세그먼트는 슬래시(/) 또는 경로의 끝에 도달할 때까지 첫 번째 문자에서 절대 경로를 구문 분석하여 가져옵니다. 각 추가 세그먼트는 이전 세그먼트 뒤의 첫 번째 문자에서 시작하여 다음 슬래시 또는 경로 끝으로 종료됩니다. (URI의 절대 경로에는 호스트 및 포트 뒤와 쿼리 및 조각 앞의 모든 항목이 포함됩니다.)

다음 예제에서는 두 URI에 대한 절대 경로 및 세그먼트를 보여 줍니다. 두 번째 예제에서는 조각 및 쿼리가 절대 경로의 일부가 아니므로 세그먼트가 아니라는 것을 보여 줍니다.

절대 URI: http://www.contoso.com/Chapters/Chapter1/Sections/Section1.htm

절대 경로: /Chapters/Chapter1/Sections/Section1.htm

세그먼트:

  • /
  • 챕터/
  • Chapter1/
  • 섹션/
  • Section1.htm

절대 URI: http://www.contoso.com/Chapters/Chapter1/Sections/Section1.htm#page1?answer=NO

절대 경로: /Chapters/Chapter1/Sections/Section1.htm

세그먼트:

  • /
  • 챕터/
  • Chapter1/
  • 섹션/
  • Section1.htm

절대 경로는 '/'로 시작하므로 첫 번째 세그먼트에는 해당 경로와 다른 항목이 포함되어 있지 않습니다.

적용 대상