EnumExtensionsTryFormatTEnum(TEnum, SpanChar, Int32, EnumFormattingOptions, ReadOnlySpanChar) Method
Tries to format the value of the current TEnum instance into the provided span of characters.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
public static bool TryFormat<TEnum>(
this TEnum value,
Span<char> destination,
out int charsWritten,
EnumFormattingOptions format = EnumFormattingOptions.Auto,
ReadOnlySpan<char> separator = default
)
where TEnum : struct, new()
<ExtensionAttribute>
Public Shared Function TryFormat(Of TEnum As {Structure, New}) (
value As TEnum,
destination As Span(Of Char),
<OutAttribute> ByRef charsWritten As Integer,
Optional format As EnumFormattingOptions = EnumFormattingOptions.Auto,
Optional separator As ReadOnlySpan(Of Char) = Nothing
) As Boolean
public:
[ExtensionAttribute]
generic<typename TEnum>
where TEnum : value class, gcnew()
static bool TryFormat(
TEnum value,
Span<wchar_t> destination,
[OutAttribute] int% charsWritten,
EnumFormattingOptions format = EnumFormattingOptions::Auto,
ReadOnlySpan<wchar_t> separator = ReadOnlySpan<wchar_t>()
)
[<ExtensionAttribute>]
static member TryFormat :
value : 'TEnum *
destination : Span<char> *
charsWritten : int byref *
?format : EnumFormattingOptions *
?separator : ReadOnlySpan<char>
(* Defaults:
let _format = defaultArg format EnumFormattingOptions.Auto
let _separator = defaultArg separator new ReadOnlySpan<char>()
*)
-> bool when 'TEnum : struct, new()
- value TEnum
- A TEnum value to be formatted.
- destination SpanChar
- The target span of characters of the formatted value.
- charsWritten Int32
- When this method returns, the number of characters that were written in destination.
- format EnumFormattingOptions (Optional)
- The formatting options. This parameter is optional.
Default value: Auto. - separator ReadOnlySpanChar (Optional)
- A span containing the separator in case of flags formatting. If empty, then comma-space (, ) separator is used. This parameter is optional.
Default value: Span<char>.Empty.
- TEnum
- The type of the enum value.
Boolean, if the formatting was successful; otherwise,
.In Visual Basic and C#, you can call this method as an instance method on any object of type
TEnum. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).