C# 根据枚举名字获取值

发布时间 2023-10-10 20:07:11作者: WantRemake
try {
    var index = (int)Enum.Parse(typeof(Enums.DepartmentEnum), entity.Contract_No);
    this.contract_no.SelectedValue = index+"";
}catch (Exception ex) { }


 public enum DepartmentEnum
 {
     请选择科室名称 = 0,
     中心领导 = 1,
     办公室 = 2,
     计划财务科 = 3,
     房产节能科 = 4,
     接待科 = 5,
     后勤服务科 = 6,
     公务用车管理科 = 7,
     公共资产管理科 = 8,
 }