Version.IUtf8SpanFormattable.TryFormat 方法

定義

嘗試將目前實例的值格式化為UTF-8到提供的位元組範圍。

C#
bool IUtf8SpanFormattable.TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider provider);

參數

utf8Destination
Span<Byte>

寫入這個實例值的範圍,其格式為位元組範圍。

bytesWritten
Int32

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

format
ReadOnlySpan<Char>

範圍,包含代表標準或自定義格式字串的字元,定義 utf8Destination可接受的格式。

provider
IFormatProvider

選擇性物件,提供 utf8Destination的特定文化特性格式資訊。

傳回

如果格式設定成功,true;否則,false

實作

適用於

產品 版本
.NET 8, 9, 10