.Net枚举的使用

public enum EnumAPPType
{
  申请 = 0
  变更 = 1,
}   

  // 设置值,和文本类型

   Array array = Enum.GetValues(typeof(DTEnums.EnumAPPType));

            if (array != null && array.Length > 0)
            {
                //  遍历枚举
                for (int i = 0; i < array.Length; i++)
                {
                    source.Add(new KeyValue<int, string> { Key = Convert.ToInt32(array.GetValue(i)), Value = System.Enum.GetName(typeof(DTEnums.EnumAPPType), Convert.ToInt32(array.GetValue(i))) });
                }

            }

posted @ 2017-10-09 18:26  亘古不变  阅读(259)  评论(0编辑  收藏  举报