Single.TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) 方法

定义

尝试将当前浮点数实例的值的格式设置为提供的字符范围。Tries to format the value of the current float number instance into the provided span of characters.

public bool TryFormat (Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = null, IFormatProvider provider = null);
member this.TryFormat : Span<char> * int * ReadOnlySpan<char> * IFormatProvider -> bool
Public Function TryFormat (destination As Span(Of Char), ByRef charsWritten As Integer, Optional format As ReadOnlySpan(Of Char) = null, Optional provider As IFormatProvider = null) As Boolean

参数

destination
Span<Char>

此方法返回时,此实例的值将设置为字符范围格式。When this method returns, this instance's value formatted as a span of characters.

charsWritten
Int32

此方法返回时,为写入到 destination 的字符数。When this method returns, the number of characters that were written in destination.

format
ReadOnlySpan<Char>

一个包含字符的范围,这些字符表示定义可接受的 destination 格式的标准或自定义格式字符串。A span containing the charactes that represent a standard or custom format string that defines the acceptable format for destination.

provider
IFormatProvider

一个可选对象,提供有关 destination 的区域性特定格式设置信息。An optional object that supplies culture-specific formatting information for destination.

返回

如果格式设置成功,则为 true;否则为 falsetrue if the formatting was successful; otherwise, false.

适用于