//定义枚举enum WorkType { 工程师,教师,学生 }//遍历Type work = typeof(WorkType);// 检索指定枚举中常数名称的数组,返回一个string类型的数组string[] temp = Enum.GetNames(work);// 接下来通过遍历数组,取出枚举中的值foreach (string str in temp){ Console.WriteLine( "{0} : {1}" , str, (int)Enum.Parse(work, str) );} 结果输出:工程师:0 教师:1 学生:2 相关文章: 2021-09-24 2021-10-18 2021-12-06 2021-09-24 2021-09-24 2021-09-24 2018-03-01 2021-08-14