Syntax:
object Enum.ToObject(Type enumType, Byte value);
object Enum.ToObject(Type enumType, Int16 value);
object Enum.ToObject(Type enumType, Int32 value);
object Enum.ToObject(Type enumType, Int64 value);
object Enum.ToObject(Type enumType, Object value);
object Enum.ToObject(Type enumType, SByte value);
object Enum.ToObject(Type enumType, UInt16 value);
object Enum.ToObject(Type enumType, UInt32 value);
object Enum.ToObject(Type enumType, UInt64 value);
Parameter:
- enumType : Type of enum object.
- value : Value to be converted to object.
Return value:
This method returns the object on the basis of the passed value.
Exception:
- System.ArgumentException
- System.ArgumentNullException
-
Program:
The source code to demonstrate the use of ToObject() method of Enum class is given below. The given program is compiled and executed successfully.
Output: