zoukankan      html  css  js  c++  java
  • 枚举转集合

    using System;  
    using System.Collections.Generic;  
    using System.ComponentModel;  
    namespace zifar.SgmhWeb.CommonMethod  
    {  
        public class EnumberHelper  
        {  
            public static List<EnumberEntity> EnumToList<T>()  
            {  
                List<EnumberEntity> list = new List<EnumberEntity>();  
                  
                foreach (var e in Enum.GetValues(typeof(T)))  
                {  
                    EnumberEntity m = new EnumberEntity();  
                    object[] objArr = e.GetType().GetField(e.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), true);  
                    if(objArr!=null && objArr.Length>0)  
                    {  
                        DescriptionAttribute da = objArr[0] as DescriptionAttribute;  
                        m.Desction = da.Description;  
                    }  
                    m.EnumValue = Convert.ToInt32(e);  
                    m.EnumName = e.ToString();  
                    list.Add(m);  
                }  
                return list;  
            }  
        }  
      
        public class EnumberEntity  
        {  
            /// <summary>  
            /// 枚举的描述  
            /// </summary>  
            public string Desction { set; get; }  
      
            /// <summary>  
            /// 枚举名称  
            /// </summary>  
            public string EnumName { set; get; }  
      
            /// <summary>  
            /// 枚举对象的值  
            /// </summary>  
            public int EnumValue { set; get; }  
        }  
    }  
    复制代码
    复制代码
    public enum QxItem  
            {  
                [Description("查看")]  
                Show=0,  
                [Description("新增")]  
                Add=1,  
                [Description("编辑")]  
                Edit=2,  
                [Description("删除")]  
                Del=3,  
                [Description("审批")]  
                Sp=4,  
                [Description("导出")]  
                Export=5,  
                [Description("同步")]  
                Sync=6,  
                [Description("打印")]  
                Print=7  
            }  
  • 相关阅读:
    DNS隧道
    记录上锁(fcntl)
    posix对线程的调整
    MySQL创建存储过程
    MySQL的WHERE语句中BETWEEN与IN的用法和他们的区别
    mysql中distinct
    线程的工作方式-流水线
    可执行程序的生成过程
    线程高级编程
    time函数及其用法
  • 原文地址:https://www.cnblogs.com/wdnrsjd/p/8028666.html
Copyright © 2011-2022 走看看