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