Utf8Parser.TryParse 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
TryParse(ReadOnlySpan<Byte>, Boolean, Int32, Char)
解析 Utf8 字串開頭的 a Boolean 。
public static bool TryParse(ReadOnlySpan<byte> source, out bool value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * bool * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Boolean, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Boolean
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。 支援的格式有 'G'、 'l'、 default和 。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
解析方式不區分大小寫。 格式參數會經過驗證以確保其被支援;然而,所有支援的格式都會被一視同仁。
適用於
TryParse(ReadOnlySpan<Byte>, Byte, Int32, Char)
解析 Utf8 字串開頭的 a Byte 。
public static bool TryParse(ReadOnlySpan<byte> source, out byte value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * byte * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Byte, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Byte
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 |
|---|---|
| G/g(預設) | |
| D/d | 122 |
| 不/n | 122 |
| X/x | 7a |
適用於
TryParse(ReadOnlySpan<Byte>, DateTime, Int32, Char)
解析 Utf8 字串開頭的 a DateTime 。
public static bool TryParse(ReadOnlySpan<byte> source, out DateTime value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * DateTime * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As DateTime, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- DateTime
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 | Comments |
|---|---|---|
| G(預設) | 05/25/2017 10:30:15 | |
| R | 2017年1月3日 星期二 08:08:05 GMT | (RFC 1123) |
| l | 2017年1月3日 星期二 08:08:05 GMT | (小寫 RFC 1123) |
| O | 2017-06-12T05:30:45.7680000-07:00 | (可往返) |
適用於
TryParse(ReadOnlySpan<Byte>, DateTimeOffset, Int32, Char)
解析 Utf8 字串開頭的 a DateTimeOffset 。
public static bool TryParse(ReadOnlySpan<byte> source, out DateTimeOffset value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * DateTimeOffset * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As DateTimeOffset, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- DateTimeOffset
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 | Comments |
|---|---|---|
| G(預設) | 05/25/2017 10:30:15 | |
| R | 2017年1月3日 星期二 08:08:05 GMT | (RFC 1123) |
| l | 2017年1月3日 星期二 08:08:05 GMT | (小寫 RFC 1123) |
| O | 2017-06-12T05:30:45.7680000-07:00 | (可往返) |
適用於
TryParse(ReadOnlySpan<Byte>, Decimal, Int32, Char)
解析 Utf8 字串開頭的 a Decimal 。
public static bool TryParse(ReadOnlySpan<byte> source, out decimal value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * decimal * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Decimal, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Decimal
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 | Comments |
|---|---|---|
| G/g(預設) | ||
| 女/女 | 12.45 | 固定點 |
| E/e | 1.245000e1 | 指數 |
適用於
TryParse(ReadOnlySpan<Byte>, Double, Int32, Char)
解析 Utf8 字串開頭的 a Double 。
public static bool TryParse(ReadOnlySpan<byte> source, out double value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * double * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Double, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Double
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 | Comments |
|---|---|---|
| G/g(預設) | ||
| 女/女 | 12.45 | 固定點 |
| E/e | 1.245000e1 | 指數 |
適用於
TryParse(ReadOnlySpan<Byte>, Guid, Int32, Char)
解析 Utf8 字串開頭的 a Guid 。
public static bool TryParse(ReadOnlySpan<byte> source, out Guid value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * Guid * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Guid, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Guid
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 預期賽制 |
|---|---|
| D(預設) | 嗯嗯 |
| B | {嗯嗯 |
| P | (嗯嗯 |
| N | 嗯嗯嗯 |
適用於
TryParse(ReadOnlySpan<Byte>, Int16, Int32, Char)
解析 在 Int16 Utf8 字串的開頭。
public static bool TryParse(ReadOnlySpan<byte> source, out short value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * int16 * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Short, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Int16
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 |
|---|---|
| G/g(預設) | |
| D/d | 32767 |
| 不/n | 32,767 |
| X/x | 7fff |
適用於
TryParse(ReadOnlySpan<Byte>, Int32, Int32, Char)
解析 在 Int32 Utf8 字串的開頭。
public static bool TryParse(ReadOnlySpan<byte> source, out int value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * int * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Integer, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Int32
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 |
|---|---|
| G/g(預設) | |
| D/d | 32767 |
| 不/n | 32,767 |
| X/x | 7fff |
適用於
TryParse(ReadOnlySpan<Byte>, Int64, Int32, Char)
解析 在 Int64 Utf8 字串的開頭。
public static bool TryParse(ReadOnlySpan<byte> source, out long value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * int64 * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Long, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Int64
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 |
|---|---|
| G/g(預設) | |
| D/d | 32767 |
| 不/n | 32,767 |
| X/x | 7fff |
適用於
TryParse(ReadOnlySpan<Byte>, SByte, Int32, Char)
重要
此 API 不符合 CLS 規範。
解析 在 SByte Utf8 字串的開頭。
[System.CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<byte> source, out sbyte value, out int bytesConsumed, char standardFormat = '\0');
[<System.CLSCompliant(false)>]
static member TryParse : ReadOnlySpan<byte> * sbyte * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As SByte, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- SByte
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
- 屬性
備註
支援的格式:
| 格式字串 | 範例預期格式 |
|---|---|
| G/g(預設) | |
| D/d | 122 |
| 不/n | 122 |
| X/x | 7a |
適用於
TryParse(ReadOnlySpan<Byte>, Single, Int32, Char)
解析 Utf8 字串開頭的 a Single 。
public static bool TryParse(ReadOnlySpan<byte> source, out float value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * single * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As Single, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- Single
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 範例預期格式 | Comments |
|---|---|---|
| G/g(預設) | ||
| 女/女 | 12.45 | 固定點 |
| E/e | 1.245000e1 | 指數 |
適用於
TryParse(ReadOnlySpan<Byte>, TimeSpan, Int32, Char)
解析 Utf8 字串開頭的 a TimeSpan 。
public static bool TryParse(ReadOnlySpan<byte> source, out TimeSpan value, out int bytesConsumed, char standardFormat = '\0');
static member TryParse : ReadOnlySpan<byte> * TimeSpan * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As TimeSpan, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- TimeSpan
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
備註
支援的格式:
| 格式字串 | 預期賽制 | Comments |
|---|---|---|
| c/t/T(預設) | [-][d.]hh:mm:ss[.fffffff] | (固定格式) |
| G | [-]d:hh:mm:ss.ffffffff | (一般長篇) |
| g | [-][d:][h]h:mm:ss[.f[f[f[f[f]]]]]] | (一般短篇) |
適用於
TryParse(ReadOnlySpan<Byte>, UInt16, Int32, Char)
重要
此 API 不符合 CLS 規範。
解析 Utf8 字串開頭的 a UInt16 。
[System.CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<byte> source, out ushort value, out int bytesConsumed, char standardFormat = '\0');
[<System.CLSCompliant(false)>]
static member TryParse : ReadOnlySpan<byte> * uint16 * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As UShort, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- UInt16
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
- 屬性
備註
支援的格式:
| 格式字串 | 範例預期格式 |
|---|---|
| G/g(預設) | |
| D/d | 32767 |
| 不/n | 32,767 |
| X/x | 7fff |
適用於
TryParse(ReadOnlySpan<Byte>, UInt32, Int32, Char)
重要
此 API 不符合 CLS 規範。
解析 Utf8 字串開頭的 a UInt32 。
[System.CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<byte> source, out uint value, out int bytesConsumed, char standardFormat = '\0');
[<System.CLSCompliant(false)>]
static member TryParse : ReadOnlySpan<byte> * uint32 * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As UInteger, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- UInt32
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
- 屬性
備註
支援的格式:
| 格式字串 | 範例預期格式 |
|---|---|
| G/g(預設) | |
| D/d | 32767 |
| 不/n | 32,767 |
| X/x | 7fff |
適用於
TryParse(ReadOnlySpan<Byte>, UInt64, Int32, Char)
重要
此 API 不符合 CLS 規範。
解析 Utf8 字串開頭的 a UInt64 。
[System.CLSCompliant(false)]
public static bool TryParse(ReadOnlySpan<byte> source, out ulong value, out int bytesConsumed, char standardFormat = '\0');
[<System.CLSCompliant(false)>]
static member TryParse : ReadOnlySpan<byte> * uint64 * int * char -> bool
Public Shared Function TryParse (source As ReadOnlySpan(Of Byte), ByRef value As ULong, ByRef bytesConsumed As Integer, Optional standardFormat As Char = '\0') As Boolean
參數
- source
- ReadOnlySpan<Byte>
解析 Utf8 字串。
- value
- UInt64
當方法回傳時,包含從 source中解析出來的值,若解析操作成功。
- bytesConsumed
- Int32
若解析操作成功,則包含解析後子串的位元組長度,當方法回傳時。 若方法失敗,則 bytesConsumed 設為 0。
- standardFormat
- Char
Utf8字串的預期格式。
傳回
true 為了成功; false 如果該字串在語法上不成立,或發生溢位或下溢位。
- 屬性
備註
支援的格式:
| 格式字串 | 範例預期格式 |
|---|---|
| G/g(預設) | |
| D/d | 32767 |
| 不/n | 32,767 |
| X/x | 7fff |