C# Uri Uri(Uri, String, Boolean)

Description

Uri Uri(Uri, String, Boolean) initializes a new instance of the Uri class based on the specified base and relative URIs, with explicit control of character escaping.

Syntax

Uri.Uri(Uri, String, Boolean) has the following syntax.


[ObsoleteAttribute("The constructor has been deprecated. Please new Uri(Uri, string). The dontEscape parameter is deprecated and is always false. http://go.microsoft.com/fwlink/?linkid=14202")]
public Uri(/*from   w w  w. ja v  a2 s . co m*/
  Uri baseUri,
  string relativeUri,
  bool dontEscape
)

Parameters

Uri.Uri(Uri, String, Boolean) has the following parameters.

  • baseUri - The base URI.
  • relativeUri - The relative URI to add to the base URI.
  • dontEscape - true if uriString is completely escaped; otherwise, false. See Remarks.

Example

The following example creates a new instance of the Uri class by combining the relative URIs http://www.java2s.com and Hello%20World.htm to form an absolute URI.


//from  w w w.  j av a  2  s  .  c  o  m
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Uri baseUri = new Uri("http://www.java2s.com");
    Uri myUri = new Uri(baseUri, "Hello%20World.htm",false);

    System.Console.WriteLine(myUri);
  }
}
    

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