public class Program
{
public static void Main(string[] args)
{
Uri uri = new Uri("http://www.Miscrosoft.com/SomeFolder/SomeFile.html?Order=true");
Uri baseUri1 = new Uri("http://www.Miscrosoft.com/SomeFolder/");
Uri baseUri2 = new Uri("http://www.Miscrosoft.com/");
Console.WriteLine("OriginalString : {0}", uri.OriginalString); // http://www.Miscrosoft.com/SomeFolder/SomeFile.html?Order=true
Console.WriteLine();
Console.WriteLine("Scheme : {0}", uri.Scheme); // http
Console.WriteLine("Host : {0}", uri.Host); // www.Miscrosoft.com
Console.WriteLine("DnsSafeHost : {0}", uri.DnsSafeHost); // www.Miscrosoft.com
Console.WriteLine("Port : {0}", uri.Port); // 80
Console.WriteLine("IsDefaultPort : {0}", uri.IsDefaultPort); // True
Console.WriteLine("Query : {0}", uri.Query); // ?Order=true
Console.WriteLine();
Console.WriteLine("AbsoluteUri : {0}", uri.AbsoluteUri); // http://www.Miscrosoft.com/SomeFolder/SomeFile.html?Order=true
Console.WriteLine("LocalPath : {0}", uri.LocalPath); // /SomeFolder/SomeFile.html
Console.WriteLine("AbsolutePath : {0}", uri.AbsolutePath); // /SomeFolder/SomeFile.html
Console.WriteLine("PathAndQuery : {0}", uri.PathAndQuery); // /SomeFolder/SomeFile.html?Order=true
Console.WriteLine("Segments[0]={0} | Segments[1]={1} | Segments[2]={2}", uri.Segments[0], uri.Segments[1], uri.Segments[2]);
// Segments[0]=/ | Segments[1]=SomeFolder/ | Segments[2]=SomeFile.html
Console.WriteLine("Fragment : {0}", uri.Fragment);
Console.WriteLine();
Console.WriteLine("IsBaseOf : {0}", uri.IsBaseOf(baseUri1)); // True
Console.WriteLine("IsBaseOf : {0}", uri.IsBaseOf(baseUri2)); // False
Console.ReadLine();
}
}