Uri.TryCreate 方法
定義
多載
TryCreate(String, UriKind, Uri) |
使用指定的 Uri 執行個體和 String,建立新的 UriKind。Creates a new Uri using the specified String instance and a UriKind. |
TryCreate(Uri, String, Uri) |
使用指定的基底和相對 Uri 執行個體,建立新的 String。Creates a new Uri using the specified base and relative String instances. |
TryCreate(Uri, Uri, 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
參數
- uriKind
- UriKind
URI 的類型。The type of the Uri.
傳回
如果已成功建立 Uri 則為 true
,否則為 false
。true
if the Uri was successfully created; otherwise, false
.
備註
如果此方法傳回 true
,則新的 Uri 會在中 result
。If this method returns true
, the new Uri is in result
.
適用於
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
參數
- baseUri
- Uri
基底 URI。The base URI.
- relativeUri
- String
要加入基底 Uri 之相對 URI 的字串表示。The string representation of the relative URI to add to the base Uri.
- result
- Uri
當這個方法傳回時,會包含從 Uri 和 baseUri
建構的 relativeUri
。When this method returns, contains a Uri constructed from baseUri
and relativeUri
. 這個參數會以未初始化的狀態傳遞。This parameter is passed uninitialized.
傳回
如果已成功建立 Uri 則為 true
,否則為 false
。true
if the Uri was successfully created; otherwise, false
.
備註
如果此方法傳回 true
,則新的 Uri 會在中 result
。If this method returns true
, the new Uri is in result
.
適用於
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
參數
- baseUri
- Uri
基底 URI。The base URI.
- result
- Uri
當這個方法傳回時,會包含從 Uri 和 baseUri
建構的 relativeUri
。When this method returns, contains a Uri constructed from baseUri
and relativeUri
. 這個參數會以未初始化的狀態傳遞。This parameter is passed uninitialized.
傳回
如果已成功建立 Uri 則為 true
,否則為 false
。true
if the Uri was successfully created; otherwise, false
.
例外狀況
baseUri
為 null
。baseUri
is null
.
備註
如果此方法傳回 true
,則新的 Uri 會在中 result
。If this method returns true
, the new Uri is in result
.
這個方法會建立 URI、將它置於標準格式,然後進行驗證。This method constructs the URI, puts it in canonical form, and validates it. 如果發生未處理的例外狀況,此方法會將它攔截。If an unhandled exception occurs, this method catches it. 如果您想要建立 Uri ,並取得例外狀況,請使用其中一個 Uri 函數。If you want to create a Uri and get exceptions use one of the Uri constructors.