.NET之枚举

假如有以下枚举:

public enum eState
{
    Pass = 1,
    Fail = -1,
    Invalid = 0,
}

 

 

1. 取出枚举的列表

public IEnumerable<eRoomState> RoomStateList
{
       get
       {
             return Enum.GetValues(typeof(eRoomState)).Cast<eRoomState>();
        }
}

  

2. 根据KEY获取枚举的VALUE值

int state = (int)Enum.Parse(typeof(eState), "Pass");

 

posted @ 2015-07-19 15:15  Wanto_C  阅读(178)  评论(0编辑  收藏  举报