KGy SOFT

JsonValueExtensionsToJsonTEnum Method (TEnum, JsonEnumFormat, String)

KGy SOFT JSON Libraries Help
Converts the specified value to JsonValue.

Namespace:  KGySoft.Json
Assembly:  KGySoft.Json (in KGySoft.Json.dll) Version: 2.0.0
Syntax

public static JsonValue ToJson<TEnum>(
	this TEnum value,
	JsonEnumFormat format = JsonEnumFormat.PascalCase,
	string? flagsSeparator = null
)
where TEnum : struct, new()

Parameters

value
Type: TEnum
The value to convert.
format (Optional)
Type: KGySoft.JsonJsonEnumFormat
Specifies the format of the enum in the JSON value. This parameter is optional.
Default value: PascalCase.
flagsSeparator (Optional)
Type: SystemString
Specifies the separator if value consists of multiple flags. This parameter is optional.
Default value: , which uses the default ", " separator.

Type Parameters

TEnum
The type of the enumeration. Must be an Enum type.

Return Value

Type: JsonValue
A JsonValue instance that is the JSON representation of the specified value.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type . 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).
Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptionformat is not one of the defined values.
See Also

Reference