Utf8Parser.TryParse 方法

定義

多載

TryParse(ReadOnlySpan<Byte>, Boolean, Int32, Char)

從 UTF8 字串的開頭剖析 Boolean

TryParse(ReadOnlySpan<Byte>, Byte, Int32, Char)

從 UTF8 字串的開頭剖析 Byte

TryParse(ReadOnlySpan<Byte>, DateTime, Int32, Char)

從 UTF8 字串的開頭剖析 DateTime

TryParse(ReadOnlySpan<Byte>, DateTimeOffset, Int32, Char)

從 UTF8 字串的開頭剖析 DateTimeOffset

TryParse(ReadOnlySpan<Byte>, Decimal, Int32, Char)

從 UTF8 字串的開頭剖析 Decimal

TryParse(ReadOnlySpan<Byte>, Double, Int32, Char)

從 UTF8 字串的開頭剖析 Double

TryParse(ReadOnlySpan<Byte>, Guid, Int32, Char)

從 UTF8 字串的開頭剖析 Guid

TryParse(ReadOnlySpan<Byte>, Int16, Int32, Char)

從 UTF8 字串的開頭剖析 Int16

TryParse(ReadOnlySpan<Byte>, Int32, Int32, Char)

從 UTF8 字串的開頭剖析 Int32

TryParse(ReadOnlySpan<Byte>, Int64, Int32, Char)

從 UTF8 字串的開頭剖析 Int64

TryParse(ReadOnlySpan<Byte>, SByte, Int32, Char)

從 UTF8 字串的開頭剖析 SByte

TryParse(ReadOnlySpan<Byte>, Single, Int32, Char)

從 UTF8 字串的開頭剖析 Single

TryParse(ReadOnlySpan<Byte>, TimeSpan, Int32, Char)

從 UTF8 字串的開頭剖析 TimeSpan

TryParse(ReadOnlySpan<Byte>, UInt16, Int32, Char)

從 UTF8 字串的開頭剖析 UInt16

TryParse(ReadOnlySpan<Byte>, UInt32, Int32, Char)

從 UTF8 字串的開頭剖析 UInt32

TryParse(ReadOnlySpan<Byte>, UInt64, Int32, Char)

從 UTF8 字串的開頭剖析 UInt64

TryParse(ReadOnlySpan<Byte>, Boolean, Int32, Char)

來源:
Utf8Parser.Boolean.cs
來源:
Utf8Parser.Boolean.cs
來源:
Utf8Parser.Boolean.cs

從 UTF8 字串的開頭剖析 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 字串的預期格式。

傳回

若成功,則為 true;若字串語法不正確或發生溢位或反向溢位,則為 false

備註

支援的格式:

格式字串 預期的範例格式
G (預設) True/False
l true/false

適用於

TryParse(ReadOnlySpan<Byte>, Byte, Int32, Char)

來源:
Utf8Parser.Integer.Unsigned.cs
來源:
Utf8Parser.Integer.Unsigned.cs
來源:
Utf8Parser.Integer.Unsigned.cs

從 UTF8 字串的開頭剖析 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/n 122
X/x 7a

適用於

TryParse(ReadOnlySpan<Byte>, DateTime, Int32, Char)

來源:
Utf8Parser.Date.cs
來源:
Utf8Parser.Date.cs
來源:
Utf8Parser.Date.cs

從 UTF8 字串的開頭剖析 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

備註

支援的格式:

格式字串 預期的範例格式 註解
G (預設) 05/25/2017 10:30:15
R 星期二,2017 年 1 月 3 日 08:08:05 GMT (RFC 1123)
l tue, 03 jan 2017 08:08:05 gmt (小寫 RFC 1123)
O 2017-06-12T05:30:45.7680000-07:00 (來回)

適用於

TryParse(ReadOnlySpan<Byte>, DateTimeOffset, Int32, Char)

來源:
Utf8Parser.Date.cs
來源:
Utf8Parser.Date.cs
來源:
Utf8Parser.Date.cs

從 UTF8 字串的開頭剖析 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

備註

支援的格式:

格式字串 預期的範例格式 註解
G (預設) 05/25/2017 10:30:15
R 2017年1月3日08: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)

來源:
Utf8Parser.Decimal.cs
來源:
Utf8Parser.Decimal.cs
來源:
Utf8Parser.Decimal.cs

從 UTF8 字串的開頭剖析 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

備註

支援的格式:

格式字串 預期格式範例 註解
G/g (預設)
F/f 12.45 固定點
E/e 1.245000e1 指數

適用於

TryParse(ReadOnlySpan<Byte>, Double, Int32, Char)

來源:
Utf8Parser.Float.cs
來源:
Utf8Parser.Float.cs
來源:
Utf8Parser.Float.cs

從 UTF8 字串的開頭剖析 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

備註

支援的格式:

格式字串 預期格式範例 註解
G/g (預設)
F/f 12.45 固定點
E/e 1.245000e1 指數

適用於

TryParse(ReadOnlySpan<Byte>, Guid, Int32, Char)

來源:
Utf8Parser.Guid.cs
來源:
Utf8Parser.Guid.cs
來源:
Utf8Parser.Guid.cs

從 UTF8 字串的開頭剖析 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 (預設) nnnn-nnnn-nnnn-nnnn-nnnnnn
B {nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnn}
P (nnnnnn-nnnn-nnnn-nnnn-nnnn-nnnn)
N nn

適用於

TryParse(ReadOnlySpan<Byte>, Int16, Int32, Char)

來源:
Utf8Parser.Integer.Signed.cs
來源:
Utf8Parser.Integer.Signed.cs
來源:
Utf8Parser.Integer.Signed.cs

從 UTF8 字串的開頭剖析 Int16

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/n 32,767
X/x 7fff

適用於

TryParse(ReadOnlySpan<Byte>, Int32, Int32, Char)

來源:
Utf8Parser.Integer.Signed.cs
來源:
Utf8Parser.Integer.Signed.cs
來源:
Utf8Parser.Integer.Signed.cs

從 UTF8 字串的開頭剖析 Int32

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/n 32,767
X/x 7fff

適用於

TryParse(ReadOnlySpan<Byte>, Int64, Int32, Char)

來源:
Utf8Parser.Integer.Signed.cs
來源:
Utf8Parser.Integer.Signed.cs
來源:
Utf8Parser.Integer.Signed.cs

從 UTF8 字串的開頭剖析 Int64

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/n 32,767
X/x 7fff

適用於

TryParse(ReadOnlySpan<Byte>, SByte, Int32, Char)

來源:
Utf8Parser.Integer.Signed.cs
來源:
Utf8Parser.Integer.Signed.cs
來源:
Utf8Parser.Integer.Signed.cs

重要

此 API 不符合 CLS 規範。

從 UTF8 字串的開頭剖析 SByte

[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/n 122
X/x 7a

適用於

TryParse(ReadOnlySpan<Byte>, Single, Int32, Char)

來源:
Utf8Parser.Float.cs
來源:
Utf8Parser.Float.cs
來源:
Utf8Parser.Float.cs

從 UTF8 字串的開頭剖析 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

備註

支援的格式:

格式字串 預期為 fornmat 的範例 註解
G/g (預設)
F/f 12.45 固定點
E/e 1.245000e1 指數

適用於

TryParse(ReadOnlySpan<Byte>, TimeSpan, Int32, Char)

來源:
Utf8Parser.TimeSpan.cs
來源:
Utf8Parser.TimeSpan.cs
來源:
Utf8Parser.TimeSpan.cs

從 UTF8 字串的開頭剖析 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

備註

支援的格式:

格式字串 預期的格式 註解
c/t/T (預設) [-][d.]hh:mm:ss[.fffffff] (常數格式)
G [-]d:hh:mm:ss.fffffff (一般長)
g [-][d:][h]h:mm:ss[.f[f[f[f[f[f[f]]]]]] (一般簡短)

適用於

TryParse(ReadOnlySpan<Byte>, UInt16, Int32, Char)

來源:
Utf8Parser.Integer.Unsigned.cs
來源:
Utf8Parser.Integer.Unsigned.cs
來源:
Utf8Parser.Integer.Unsigned.cs

重要

此 API 不符合 CLS 規範。

從 UTF8 字串的開頭剖析 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/n 32,767
X/x 7fff

適用於

TryParse(ReadOnlySpan<Byte>, UInt32, Int32, Char)

來源:
Utf8Parser.Integer.Unsigned.cs
來源:
Utf8Parser.Integer.Unsigned.cs
來源:
Utf8Parser.Integer.Unsigned.cs

重要

此 API 不符合 CLS 規範。

從 UTF8 字串的開頭剖析 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/n 32,767
X/x 7fff

適用於

TryParse(ReadOnlySpan<Byte>, UInt64, Int32, Char)

來源:
Utf8Parser.Integer.Unsigned.cs
來源:
Utf8Parser.Integer.Unsigned.cs
來源:
Utf8Parser.Integer.Unsigned.cs

重要

此 API 不符合 CLS 規範。

從 UTF8 字串的開頭剖析 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/n 32,767
X/x 7fff

適用於