Upraviť

Zdieľať cez


Uri.TryCreate Method

Definition

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

Overloads

TryCreate(Uri, Uri, Uri)

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

TryCreate(Uri, String, Uri)

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

TryCreate(String, UriKind, Uri)

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

TryCreate(String, UriCreationOptions, Uri)

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

TryCreate(Uri, Uri, Uri)

Source:
UriExt.cs
Source:
UriExt.cs
Source:
UriExt.cs

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);
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

The base URI.

relativeUri
Uri

The relative URI to add to the base Uri.

result
Uri

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

Returns

true if the Uri was successfully created; otherwise, false.

Exceptions

baseUri is null.

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

TryCreate(Uri, String, Uri)

Source:
UriExt.cs
Source:
UriExt.cs
Source:
UriExt.cs

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);
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

The base URI.

relativeUri
String

The string representation of the relative URI to add to the base Uri.

result
Uri

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

Returns

true if the Uri was successfully created; otherwise, false.

Remarks

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

Applies to

TryCreate(String, UriKind, Uri)

Source:
UriExt.cs
Source:
UriExt.cs
Source:
UriExt.cs

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);
public static bool TryCreate (string? uriString, UriKind uriKind, out Uri? result);
static member TryCreate : string * UriKind * Uri -> bool
Public Shared Function TryCreate (uriString As String, uriKind As UriKind, ByRef result As Uri) As Boolean

Parameters

uriString
String

The string representation of the Uri.

uriKind
UriKind

The type of the Uri.

result
Uri

When this method returns, contains the constructed Uri.

Returns

true if the Uri was successfully created; otherwise, false.

Remarks

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

Applies to

TryCreate(String, UriCreationOptions, Uri)

Source:
UriExt.cs
Source:
UriExt.cs
Source:
UriExt.cs

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

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

Parameters

uriString
String

The string representation of the Uri.

creationOptions
UriCreationOptions

Options that control how the Uri is created and behaves.

result
Uri

When this method returns, contains the constructed Uri.

Returns

true if the Uri was successfully created; otherwise, false.

Applies to