zoukankan      html  css  js  c++  java
  • 枚举处理工具类 .net

    将枚举转化成List<T>的方法如下:

        /// <summary>
        /// 枚举处理工具类
        /// </summary>
        public class EnumHelper
        {
            /// <summary>
            /// 枚举转 List
            /// </summary>
            /// <param name="enumType">枚举Type</param>
            /// <returns>List</returns>
            public static List<TextValue> ToList(Type enumType, string textFormat = null)
            {
                List<TextValue> result = new List<TextValue>();
    
                foreach (var i in Enum.GetValues(enumType))
                {
                    var text = Enum.GetName(enumType, i);
                    result.Add(new TextValue()
                    {
                        Text = string.IsNullOrEmpty(textFormat) ? text : string.Format(textFormat, text),
                        Value = i
                    });
                }
    
                return result;
            }
        }
  • 相关阅读:
    bash编程2
    bash简介1
    grep文本处理工具
    用户的环境变量
    用户,组,权限
    yum与rmp
    逻辑卷管理
    磁盘配额
    磁盘创建
    创建计划任务
  • 原文地址:https://www.cnblogs.com/hankuikui/p/6489567.html
Copyright © 2011-2022 走看看