using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace 将枚举作为键值的形式存储
{
enum Myenum
{
First=3,
Second,
Third
}
class Program
{
static void Main(string[] args)
{
//用hashtable可以实现吗? NameValueCollection可以实现吗?
Dictionary<string, int> dictionary = new Dictionary<string, int>();
string [] enumArray=Enum.GetNames(typeof(Myenum));
for (int i = 0; i < enumArray.Length; i++)
{
dictionary.Add(enumArray[i],(int) Enum.Parse(typeof(Myenum), enumArray[i]));
}
Console.WriteLine(dictionary["First"]);
Console.WriteLine(dictionary["Second"]);
Console.WriteLine(dictionary["Third"]);
Console.Read();
}
}
}