C# Uri TryCreate(Uri, String, Uri)

Description

Uri TryCreate(Uri, String, Uri) creates a new Uri using the specified base and relative String instances.

Syntax

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


public static bool TryCreate(
  Uri baseUri,/*w w  w.  j a va 2  s  .c o m*/
  string relativeUri,
  out Uri result
)

Parameters

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

  • baseUri - The base Uri.
  • relativeUri - The relative Uri, represented as a String, to add to the base Uri.
  • result - When this method returns, contains a Uri constructed from baseUri and relativeUri. This parameter is passed uninitialized.

Returns

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

Example


/*from  www.  j  a v  a  2 s.c  om*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Uri uri = new Uri("http://java2s.com");
    String relative = "asd.htm";
    Uri result = null;
    Uri.TryCreate(uri,relative,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