EnumExtensionsGetDefinedOrDefaultTEnum Method
Returns value if it is defined in TEnum;
otherwise, returns defaultValue, even if it is undefined.
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
public static TEnum GetDefinedOrDefault<TEnum>(
this TEnum value,
TEnum defaultValue = null
)
where TEnum : struct, new()
<ExtensionAttribute>
Public Shared Function GetDefinedOrDefault(Of TEnum As {Structure, New}) (
value As TEnum,
Optional defaultValue As TEnum = Nothing
) As TEnum
public:
[ExtensionAttribute]
generic<typename TEnum>
where TEnum : value class, gcnew()
static TEnum GetDefinedOrDefault(
TEnum value,
TEnum defaultValue = nullptr
)
[<ExtensionAttribute>]
static member GetDefinedOrDefault :
value : 'TEnum *
?defaultValue : 'TEnum
(* Defaults:
let _defaultValue = defaultArg defaultValue null
*)
-> 'TEnum when 'TEnum : struct, new()
- value TEnum
- A TEnum value.
- 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.
- TEnum
- The type of the enum value.
TEnumvalue if it is defined in
TEnum;
otherwise,
defaultValue, even if it is undefined.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).