C# Uri Segments

Description

Uri Segments gets an array containing the path segments that make up the specified URI.

Syntax

Uri.Segments has the following syntax.


public string[] Segments { get; }

Example

The following example creates a Uri instance with 3 segments and displays the segments on the screen.


//from  ww  w  . j  av  a2 s .c  o  m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Uri uriAddress1 = new Uri("http://www.java2s.com/title/index.htm");
    Console.WriteLine("The parts are {0}, {1}, {2}", 
                       uriAddress1.Segments[0], 
                       uriAddress1.Segments[1], 
                       uriAddress1.Segments[2]);

  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version