EnumTEnumGetDefinedOrDefault(ReadOnlySpanChar, TEnum) Method

Returns the TEnum value associated with value if it is defined in TEnum; otherwise, returns defaultValue, even if it is undefined. The search is case-sensitive.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public static TEnum GetDefinedOrDefault(
	ReadOnlySpan<char> value,
	TEnum defaultValue = null
)

Parameters

value  ReadOnlySpanChar
A ReadOnlySpan<char> value representing a field name in the enumeration.
defaultValue  TEnum  (Optional)
A TEnum value to return if value is not defined in TEnum. It does not needed to be a defined value. This parameter is optional.
Default value: The bitwise zero value of TEnum.

Return Value

TEnum
The TEnum value associated with value if it is defined in TEnum; otherwise, defaultValue, even if it is undefined.

See Also