C# Uri Uri(String, UriKind)

Description

Uri Uri(String, UriKind) initializes a new instance of the Uri class with the specified URI. This constructor allows you to specify if the URI string is a relative URI, absolute URI, or is indeterminate.

Syntax

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


public Uri(
  string uriString,
  UriKind uriKind
)

Parameters

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

  • uriString - A string that identifies the resource to be represented by the Uri instance.
  • uriKind - Specifies whether the URI string is a relative URI, absolute URI, or is indeterminate.

Example


//from   ww  w . j a v a  2 s .  c  om
using System;
public class MainClass
{
    public static void Main(String[] argv)
    {
        Uri myUri = new Uri("http://www.java2s.com", UriKind.Absolute);
        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