C# Uri Uri(Uri, Uri)

Description

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

Syntax

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


public Uri(
  Uri baseUri,
  Uri relativeUri
)

Parameters

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

  • baseUri - An absolute Uri that is the base for the new Uri instance.
  • relativeUri - A relative Uri instance that is combined with baseUri.

Example

This example creates an absolute Uri instance, absoluteUri, and a relative Uri instance, relativeUri. A new Uri instance, combinedUri, is then created from these two instances.


/*from w w  w.j a  v  a  2  s  .  c o m*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    // Create an absolute Uri from a string.
    Uri absoluteUri = new Uri("http://www.java2s.com/");
    
    Uri relativeUri = new Uri("/catalog/shownew.htm?date=today", UriKind.Relative);
    
    
    // Create a new Uri from an absolute Uri and a relative Uri.
    Uri combinedUri = new Uri(absoluteUri, relativeUri);
    Console.WriteLine(combinedUri.AbsoluteUri);

  }
}
    

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