Redigeeri

Jagamisviis:


Enum.TryFormat<TEnum> Method

Definition

Tries to format the value of the enumerated type instance into the provided span of characters.

public static bool TryFormat<TEnum> (TEnum value, Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default) where TEnum : struct;
static member TryFormat : 'Enum * Span<char> * int * ReadOnlySpan<char> -> bool (requires 'Enum : struct)
Public Shared Function TryFormat(Of TEnum As Structure) (value As TEnum, destination As Span(Of Char), ByRef charsWritten As Integer, Optional format As ReadOnlySpan(Of Char) = Nothing) As Boolean

Type Parameters

TEnum

Parameters

value
TEnum
destination
Span<Char>

The span into which to write the instance's value formatted as a span of characters.

charsWritten
Int32

When this method returns, contains the number of characters that were written in destination.

format
ReadOnlySpan<Char>

A span containing the character that represents the standard format string that defines the acceptable format of destination. This value can be empty, or "g", "d", "f", or "x".

Returns

true if the formatting was successful; otherwise, false if the destination span wasn't large enough to contain the formatted value.

Exceptions

The format parameter contains an invalid value.

Applies to