EnumExtensionsTryFormatTEnum(TEnum, SpanByte, Int32, EnumFormattingOptions, ReadOnlySpanByte) Method
Tries to format the value of the current TEnum instance into the provided span of UTF-8 bytes.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public static bool TryFormat<TEnum>(
this TEnum value,
Span<byte> utf8Destination,
out int bytesWritten,
EnumFormattingOptions format = EnumFormattingOptions.Auto,
ReadOnlySpan<byte> separator = default
)
where TEnum : struct, new()
<ExtensionAttribute>
Public Shared Function TryFormat(Of TEnum As {Structure, New}) (
value As TEnum,
utf8Destination As Span(Of Byte),
<OutAttribute> ByRef bytesWritten As Integer,
Optional format As EnumFormattingOptions = EnumFormattingOptions.Auto,
Optional separator As ReadOnlySpan(Of Byte) = Nothing
) As Boolean
public:
[ExtensionAttribute]
generic<typename TEnum>
where TEnum : value class, gcnew()
static bool TryFormat(
TEnum value,
Span<unsigned char> utf8Destination,
[OutAttribute] int% bytesWritten,
EnumFormattingOptions format = EnumFormattingOptions::Auto,
ReadOnlySpan<unsigned char> separator = ReadOnlySpan<unsigned char>()
)
[<ExtensionAttribute>]
static member TryFormat :
value : 'TEnum *
utf8Destination : Span<byte> *
bytesWritten : int byref *
?format : EnumFormattingOptions *
?separator : ReadOnlySpan<byte>
(* Defaults:
let _format = defaultArg format EnumFormattingOptions.Auto
let _separator = defaultArg separator new ReadOnlySpan<byte>()
*)
-> bool when 'TEnum : struct, new()
- value TEnum
- A TEnum value to be formatted.
- utf8Destination SpanByte
- The target span of UTF-8 bytes of the formatted value.
- bytesWritten Int32
- When this method returns, the number of bytes that were written in utf8Destination.
- format EnumFormattingOptions (Optional)
- The formatting options. This parameter is optional.
Default value: Auto. - separator ReadOnlySpanByte (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<byte>.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).