Convert object with an integer value to enum in CSharp
Description
The following code shows how to convert object with an integer value to enum.
Example
/*w ww.j a va2 s. c o m*/
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.