C# Uri OriginalString

Description

Uri OriginalString gets the original URI string that was passed to the Uri constructor.

Syntax

Uri.OriginalString has the following syntax.


public string OriginalString { get; }

Example

The following example creates a new Uri instance from a string. It illustrates the difference between the value returned from OriginalString, which returns the string that was passed to the constructor, and from a call to ToString, which returns the canonical form of the string.


//w ww.j  a v a  2s . c  o m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    // Create a new Uri from a string address.
    Uri uriAddress = new Uri("HTTP://www.java2s.com:80//a%20and%20b.htm");
    
    // The following outputs "http://www.java2s.com/a and b.htm".
    Console.WriteLine(uriAddress.ToString()); 
    
    // The following outputs "HTTP://www.java2s.com:80//a%20and%20b.htm".
    Console.WriteLine(uriAddress.OriginalString);
    

  }
}
    

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