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

定義

嘗試將目前整數執行個體的值格式化為所提供的字元範圍。Tries to format the value of the current integer 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.

適用於