Uri.TryCreate Uri.TryCreate Uri.TryCreate Uri.TryCreate Method

Definition

Creates a new Uri. Does not throw an exception if the Uri cannot be created.

Overloads

TryCreate(String, UriKind, Uri) TryCreate(String, UriKind, Uri) TryCreate(String, UriKind, Uri)

Creates a new Uri using the specified String instance and a UriKind.

TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri)

Creates a new Uri using the specified base and relative String instances.

TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri)

Creates a new Uri using the specified base and relative Uri instances.

TryCreate(String, UriKind, Uri) TryCreate(String, UriKind, Uri) TryCreate(String, UriKind, Uri)

Creates a new Uri using the specified String instance and a UriKind.

public:
 static bool TryCreate(System::String ^ uriString, UriKind uriKind, [Runtime::InteropServices::Out] Uri ^ % result);
public static bool TryCreate (string uriString, UriKind uriKind, out Uri result);
static member TryCreate : string * UriKind * Uri -> bool

Parameters

uriString
String String String String

The String representing the Uri.

uriKind
UriKind UriKind UriKind UriKind

The type of the Uri.

result
Uri Uri Uri Uri

When this method returns, contains the constructed Uri.

Returns

A Boolean value that is true if the Uri was successfully created; otherwise, false.

Remarks

If this method returns true, the new Uri is in result.

TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri) TryCreate(Uri, String, Uri)

Creates a new Uri using the specified base and relative String instances.

public:
 static bool TryCreate(Uri ^ baseUri, System::String ^ relativeUri, [Runtime::InteropServices::Out] Uri ^ % result);
public static bool TryCreate (Uri baseUri, string relativeUri, out Uri result);
static member TryCreate : Uri * string * Uri -> bool
Public Shared Function TryCreate (baseUri As Uri, relativeUri As String, ByRef result As Uri) As Boolean

Parameters

baseUri
Uri Uri Uri Uri

The base Uri.

relativeUri
String String String String

The relative Uri, represented as a String, to add to the base Uri.

result
Uri Uri Uri Uri

When this method returns, contains a Uri constructed from baseUri and relativeUri. This parameter is passed uninitialized.

Returns

A Boolean value that is true if the Uri was successfully created; otherwise, false.

Remarks

If this method returns true, the new Uri is in result.

TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri) TryCreate(Uri, Uri, Uri)

Creates a new Uri using the specified base and relative Uri instances.

public:
 static bool TryCreate(Uri ^ baseUri, Uri ^ relativeUri, [Runtime::InteropServices::Out] Uri ^ % result);
public static bool TryCreate (Uri baseUri, Uri relativeUri, out Uri result);
static member TryCreate : Uri * Uri * Uri -> bool
Public Shared Function TryCreate (baseUri As Uri, relativeUri As Uri, ByRef result As Uri) As Boolean

Parameters

baseUri
Uri Uri Uri Uri

The base Uri.

relativeUri
Uri Uri Uri Uri

The relative Uri to add to the base Uri.

result
Uri Uri Uri Uri

When this method returns, contains a Uri constructed from baseUri and relativeUri. This parameter is passed uninitialized.

Returns

A Boolean value that is true if the Uri was successfully created; otherwise, false.

Exceptions

Remarks

If this method returns true, the new Uri is in result.

This method constructs the URI, puts it in canonical form, and validates it. If an unhandled exception occurs, this method catches it. If you want to create a Uri and get exceptions use one of the Uri constructors.

Applies to