1. 程式人生 > >.Net枚舉的使用

.Net枚舉的使用

name values null 申請 amp pty length del str

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))) });
}

}

.Net枚舉的使用