Version.TryFormat 方法

定義

多載

TryFormat(Span<Char>, Int32, Int32)

嘗試將此版本執行個體格式化為字元延伸。

TryFormat(Span<Byte>, Int32, Int32)

嘗試將此版本實例格式化為位元組範圍。

TryFormat(Span<Char>, Int32)

嘗試將此版本執行個體格式化為字元延伸。

TryFormat(Span<Byte>, Int32)

嘗試將此版本實例格式化為位元組範圍。

TryFormat(Span<Char>, Int32, Int32)

來源:
Version.cs
來源:
Version.cs
來源:
Version.cs

嘗試將此版本執行個體格式化為字元延伸。

C#
public bool TryFormat(Span<char> destination, int fieldCount, out int charsWritten);

參數

destination
Span<Char>

要在其中寫入此實例值的範圍,其格式為字元範圍。

fieldCount
Int32

要傳回的元件數目。 值的範圍介於 0 到 4 之間。

charsWritten
Int32

當這個方法傳回時,會包含以 寫入 destination 的字元數。

傳回

若格式化成功則為 true,否則為 false

適用於

.NET 10 和其他版本
產品 版本
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

TryFormat(Span<Byte>, Int32, Int32)

來源:
Version.cs
來源:
Version.cs

嘗試將此版本實例格式化為位元組範圍。

C#
public bool TryFormat(Span<byte> utf8Destination, int fieldCount, out int bytesWritten);

參數

utf8Destination
Span<Byte>

要在其中寫入這個實例值的範圍,其格式為 UTF-8 位元組的範圍。

fieldCount
Int32

要傳回的元件數目。 值的範圍介於 0 到 4 之間。

bytesWritten
Int32

當這個方法傳回時,包含以 寫入 utf8Destination 的位元組數目。

傳回

若格式化成功則為 true,否則為 false

適用於

.NET 10 和其他版本
產品 版本
.NET 8, 9, 10

TryFormat(Span<Char>, Int32)

來源:
Version.cs
來源:
Version.cs
來源:
Version.cs

嘗試將此版本執行個體格式化為字元延伸。

C#
public bool TryFormat(Span<char> destination, out int charsWritten);

參數

destination
Span<Char>

要在其中寫入此實例值的範圍,其格式為字元範圍。

charsWritten
Int32

當這個方法傳回時,會包含以 寫入 destination 的字元數。

傳回

若格式化成功則為 true,否則為 false

適用於

.NET 10 和其他版本
產品 版本
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

TryFormat(Span<Byte>, Int32)

來源:
Version.cs
來源:
Version.cs

嘗試將此版本實例格式化為位元組範圍。

C#
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten);

參數

utf8Destination
Span<Byte>

要在其中寫入這個實例值的範圍,其格式為 UTF-8 位元組的範圍。

bytesWritten
Int32

當這個方法傳回時,包含以 寫入 utf8Destination 的位元組數目。

傳回

若格式化成功則為 true,否則為 false

適用於

.NET 10 和其他版本
產品 版本
.NET 8, 9, 10