C# Uri TryCreate(String, UriKind, Uri)

Description

Uri TryCreate(String, UriKind, Uri) creates a new Uri using the specified String instance and a UriKind.

Syntax

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


public static bool TryCreate(
  string uriString,/* w w w .ja  va2  s .c o m*/
  UriKind uriKind,
  out Uri result
)

Parameters

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

  • uriString - The String representing the Uri.
  • uriKind - The type of the Uri.
  • result - When this method returns, contains the constructed Uri.

Returns

Uri.TryCreate(String, UriKind, Uri) method returns A Boolean value that is true if the Uri was successfully created; otherwise, false.

Example


using System;//from   w  w  w.  ja  va2  s  .  c om
public class MainClass
{
    public static void Main(String[] argv)
    {
        Uri result = null;
        Uri.TryCreate("http://java2s.com", UriKind.Absolute, out result);
        System.Console.WriteLine(result);
    }
}

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