Complex.TryFormat 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
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
參數
- 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
參數
- bytesWritten
- Int32
- format
- ReadOnlySpan<Char>
- provider
- IFormatProvider
傳回
實作
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應