枚舉與整型之間的轉換

顯示轉換

 

enum Color
 
{
            RED,GREEN,BLUE
  }


枚舉轉換爲整形
int a = (int)Color.RED;

整形轉換爲枚舉
Color c;
= (Color) 1;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章