EnumExtensionsGetEnumValueOrDefault(Object, Type, Object) Method

Gets the enumeration constant for value, if defined in the enumeration, or a default value.

Definition

Namespace: Gemstone.EnumExtensions
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.110 -- Release Build+3e0464f4461df4d3e1175b13966eb47ff832554d
public static Object? GetEnumValueOrDefault(
	this Object? value,
	Type type,
	Object defaultValue = null
)

Parameters

value  Object
Value to attempt to return from enumeration.
type  Type
Type of the enumeration.
defaultValue  Object  (Optional)
Value to return if enumeration value is not found.

Return Value

Object
Enumeration value specified, if found, or a default value.

Usage Note

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

Remarks

If a default value is not defined, first enumeration value will be used.

Exceptions

ArgumentNullExceptiontype or value is null.
ArgumentExceptiontype is not an enum. -or- The type of value is not of type type. -or- The type of value is not an underlying type of type.
InvalidOperationExceptionvalue is not type SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, or UInt64, or String.

See Also