Char.IUtf8SpanFormattable.TryFormat 方法

定义

尝试将当前实例的值格式化为 UTF-8,并将其设置为提供的字节范围。

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