C# Enum ToObject(Type, Int32)
Description
Enum ToObject(Type, Int32)
converts the specified 32-bit
signed integer to an enumeration member.
Syntax
Enum.ToObject(Type, Int32)
has the following syntax.
[ComVisibleAttribute(true)]/*from ww w . j a v a 2s.com*/
public static Object ToObject(
Type enumType,
int value
)
Parameters
Enum.ToObject(Type, Int32)
has the following parameters.
enumType
- The enumeration type to return.value
- The value to convert to an enumeration member.
Returns
Enum.ToObject(Type, Int32)
method returns An instance of the enumeration set to value.
Example
/*from w ww .ja v a 2 s . c om*/
using System;
enum Mammals { Cat, Dog, Horse, Dolphin };
public class MainClass
{
public static void Main(String[] argv)
{
Object obj = Enum.ToObject(Mammals.Cat.GetType(), 1);
Console.WriteLine(obj);
}
}
The code above generates the following result.