Table of Contents

Method TryFormat

Namespace
Zyl.ExSpans.Impl
Assembly
ExSpans.dll

TryFormat<TEnum>(TEnum, Span<char>, out int, ReadOnlySpan<char>)

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

Parameters

value TEnum
destination Span<char>

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

charsWritten int

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 may be empty, or "g", "d", "f", or "x".

Returns

bool

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

Type Parameters

TEnum

Exceptions

FormatException

The format parameter contains an invalid value.