bobdylan75
asked on
How to obtain the int value of an enum variable (c# vs2005)
Hi,
I have define an enum type.
So, I'd like to use the integer value associated
to the particulaer enum value.
if I have an enum typeX:
One, 1
Two, 2
Tree, 3
I'd like auto-retrieve the value 2 when I have a variable A = typeX.Two
something like Anum= enumCounter( A )
so that Anum equals to 2
Is it possible?
I have define an enum type.
So, I'd like to use the integer value associated
to the particulaer enum value.
if I have an enum typeX:
One, 1
Two, 2
Tree, 3
I'd like auto-retrieve the value 2 when I have a variable A = typeX.Two
something like Anum= enumCounter( A )
so that Anum equals to 2
Is it possible?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi,
using System;
public class EnumTest
{
enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};
public static void Main()
{
int x = (int) Days.Sun;
int y = (int) Days.Fri;
Console.WriteLine("Sun = {0}", x);
Console.WriteLine("Fri = {0}", y);
}
}
ASKER
thanks Dexter anyway
ASKER