using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
enum myenu
{
aaa = 0,
bbb = 1,
ccc = 2,
ddd = 4
// eee = "s0" 枚举的值只能为数字类型
}
internal class Program
{
static void Main(string[] args)
{
// 枚举通过key获取value
int sec = (int)myenu.aaa;
Console.WriteLine(sec);
// 枚举通过value获取key(感觉没啥用)
myenu bbc = myenu.bbb;
Console.WriteLine(Convert.ToString(bbc));
// 枚举通过一个字符串获取枚举值
string iii = "ddd";
myenu xx = (myenu)Enum.Parse(typeof(myenu), iii);
Console.WriteLine((int)xx);
Console.ReadLine();
}
}
}
``