• 【C#枚举】根据EnumName获取Value


     1         public static int GetEnumValue(Type enumType, string enumName)
     2         {
     3             try
     4             {
     5                 if (!enumType.IsEnum)
     6                     throw new ArgumentException("enumType必须是枚举类型");
     7                 var values = Enum.GetValues(enumType);
     8                 var ht = new Hashtable();
     9                 foreach(var val in values)
    10                 {
    11                     ht.Add(Enum.GetName(enumType, val), val);
    12                 }
    13                 return (int)ht[enumName];
    14             }
    15             catch (Exception e)
    16             {
    17                 throw e;
    18             }
    19         }
  • 相关阅读:
    python timeit模块用法
    boto3库限速
    golang-Beego-orm创建的坑
    Java07
    Java06
    Java04
    Java03
    c
    Mac 安装GCC
    命令: go build
  • 原文地址:https://www.cnblogs.com/tongyinaocan/p/5482101.html
Copyright © 2020-2023  润新知