I would do the following:
public enum MyNumberType {
Zero = 0, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten
}
You could do what you want with it in the following ways:
namespace ConsoleApplication
{
class Program
{
public enum MyNumberType { Zero = 0, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten }
private static int GetIntValue(MyNumberType theType) { return (int) theType; }
private static String GetStringValue(MyNumberType theType) { return Enum.GetName(typeof (MyNumberType),theType); }
private static MyNumberType GetEnumValue (int theInt) {
return (MyNumberType) Enum.Parse( typeof(MyNumberType), theInt.ToString() ); }
static void Main(string[] args)
{
Console.WriteLine( "{0} {1} {2}",
GetIntValue(MyNumberType.Five),
GetStringValue( MyNumberType.Three),
GetEnumValue(7)
);
for (int i=0; i<=10; i++)
{
Console.WriteLine("{0}", GetEnumValue(i));
}
}
}
}
Producing the following output:
5 Three Seven
Zero
One
Two
Three
Four
Five
Six
Seven
Eight
Nine
Ten
This could be extended for larger numbers and numbers not in a continuous range like so:
public enum MyNumberType {
ten= 10, Fifty=50, Hundred=100, Thousand=1000
}
Enums can be used with other types as well not just int types so this is very flexible.