Share via


Complex.TryFormat 方法

定義

多載

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

嘗試將目前實例的值格式化為提供的字元範圍。

TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

來源:
Complex.cs
來源:
Complex.cs
來源:
Complex.cs

嘗試將目前實例的值格式化為提供的字元範圍。

public:
 virtual bool TryFormat(Span<char> destination, [Runtime::InteropServices::Out] int % charsWritten, ReadOnlySpan<char> format, IFormatProvider ^ provider);
public bool TryFormat (Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider);
public bool TryFormat (Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = default);
abstract member TryFormat : Span<char> * int * ReadOnlySpan<char> * IFormatProvider -> bool
override this.TryFormat : Span<char> * int * ReadOnlySpan<char> * IFormatProvider -> bool
Public Function TryFormat (destination As Span(Of Char), ByRef charsWritten As Integer, format As ReadOnlySpan(Of Char), provider As IFormatProvider) As Boolean
Public Function TryFormat (destination As Span(Of Char), ByRef charsWritten As Integer, Optional format As ReadOnlySpan(Of Char) = Nothing, Optional provider As IFormatProvider = Nothing) As Boolean

參數

destination
Span<Char>

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

charsWritten
Int32

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

format
ReadOnlySpan<Char>

包含字元的範圍,這些字元代表的標準或自訂格式字串能定義 destination 可接受的格式。

provider
IFormatProvider

選擇性物件,其可為 destination 提供特定的文化特性格式資訊。

傳回

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

實作

備註

這個介面的實作應該會產生與相同類型實作相同的字元 ToString(String, IFormatProvider) 字串。 只有在目的地緩衝區中沒有足夠的空間時,TryFormat 才會傳回 false 。 任何其他失敗都應該擲回例外狀況。

適用於

TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

來源:
Complex.cs
來源:
Complex.cs
public bool TryFormat (Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = default);
abstract member TryFormat : Span<byte> * int * ReadOnlySpan<char> * IFormatProvider -> bool
override this.TryFormat : Span<byte> * int * ReadOnlySpan<char> * IFormatProvider -> bool
Public Function TryFormat (utf8Destination As Span(Of Byte), ByRef bytesWritten As Integer, Optional format As ReadOnlySpan(Of Char) = Nothing, Optional provider As IFormatProvider = Nothing) As Boolean

參數

utf8Destination
Span<Byte>
bytesWritten
Int32
format
ReadOnlySpan<Char>
provider
IFormatProvider

傳回

實作

適用於