Complex.TryFormat 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) |
尝试将当前实例的值格式化为提供的字符范围。 |
TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider) |
TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)
- Source:
- Complex.cs
- Source:
- Complex.cs
- Source:
- 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)
- Source:
- Complex.cs
- Source:
- 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