Uri.TryCreate Method
Definition
Overloads
TryCreate(String, UriKind, Uri) |
Creates a new Uri using the specified String instance and a UriKind. |
TryCreate(Uri, String, Uri) |
Creates a new Uri using the specified base and relative String instances. |
TryCreate(Uri, Uri, Uri) |
Creates a new Uri using the specified base and relative Uri instances. |
TryCreate(String, UriKind, Uri)
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
- uriKind
- UriKind
The type of the 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(Uri, String, Uri)
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.
- 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(Uri, Uri, Uri)
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.
- 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.