EnumExtension.cs 394 B

12345678910111213141516171819
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace gpt_api.Core.Extensions
  7. {
  8. /// <summary>
  9. /// 枚举扩展方法
  10. /// </summary>
  11. public static class EnumExtension
  12. {
  13. public static T ToEnum<T>(this string str)
  14. {
  15. return (T)Enum.Parse(typeof(T), str);
  16. }
  17. }
  18. }