共用方式為


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

傳回

實作

適用於