publicstaticclassEnumHelper{publicstaticint[]ToIntArray<T>(T[] value){int[] result =newint[value.Length];for(int i =0; i < value.Length; i++)
            result[i]=Convert.ToInt32(value[i]);return result;}publicstatic T[]FromIntArray<T>(int[] value){
        T[] result =new T[value.Length];for(int i =0; i < value.Length; i++)
            result[i]=(T)Enum.ToObject(typeof(T),value[i]);return result;}internalstatic T Parse<T>(string value, T defaultValue){if(Enum.IsDefined(typeof(T), value))return(T)Enum.Parse(typeof(T), value);int num;if(int.TryParse(value,out num)){if(Enum.IsDefined(typeof(T), num))return(T)Enum.ToObject(typeof(T), num);}return defaultValue;}}

相关文章:

  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2021-04-12
  • 2021-05-12
  • 2022-12-23
  • 2021-10-14
猜你喜欢
  • 2021-07-10
  • 2021-08-03
  • 2021-12-29
  • 2021-08-31
  • 2021-08-04
相关资源
相似解决方案