Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have defined an enum and tried to retrieve it as follows

C#
class Demo
{
    enum hello
    {
        one=1,
        two
    }
    public static void Main()
    {

        Console.WriteLine(hello.one);


        Console.ReadLine();
    }
}



Now, how do i retrieve the integer value "1" from the enum ?
Posted

 
Share this answer
 
try to use GetHashCode mehtod like below

C#
Console.WriteLine(hello.one.GetHasCode());
 
Share this answer
 
C#
Console.WriteLine((int)hello.one);

Happy Coding!
:)
 
Share this answer
 
Comments
_Amy 20-Jun-13 4:17am    
Exactly. +5!
Aarti Meswania 20-Jun-13 4:18am    
Thank you! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900