C# Uri Uri(Uri, String)

Description

Uri Uri(Uri, String) initializes a new instance of the Uri class based on the specified base URI and relative URI string.

Syntax

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


public Uri(
  Uri baseUri,
  string relativeUri
)

Parameters

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

  • baseUri - The base URI.
  • relativeUri - The relative URI to add to the base URI.

Example

The following example creates a new instance of the Uri class by combining the relative URIs http://www.java2s.com and catalog/showew.htm to form the absolute URI http://www.java2s.com/catalog/shownew.htm.


//from   ww w .  j  a v a  2  s.  c om
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Uri baseUri = new Uri("http://www.java2s.com");
    Uri myUri = new Uri(baseUri, "catalog/shownew.htm");
    Console.WriteLine(myUri.ToString());

  }
}

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