C# Enum ToObject(Type, Int64)
Description
Enum ToObject(Type, Int64)
converts the specified 64-bit
signed integer to an enumeration member.
Syntax
Enum.ToObject(Type, Int64)
has the following syntax.
[ComVisibleAttribute(true)]/* w ww . jav a 2 s . c om*/
public static Object ToObject(
Type enumType,
long value
)
Parameters
Enum.ToObject(Type, Int64)
has the following parameters.
enumType
- The enumeration type to return.value
- The value to convert to an enumeration member.
Returns
Enum.ToObject(Type, Int64)
method returns An instance of the enumeration set to value.
Example
/*from ww w. j a va 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(),0);
Console.WriteLine(obj);
}
}
The code above generates the following result.