http://www.aygfsteel.com/ebecket 返還網
          隨筆-140  評論-11  文章-131  trackbacks-0
          C#]Enum枚舉類型使用總結
          public enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

          The entries of the Colors Enum are:
          Red
          Green
          Blue
          Yellow


          根據name獲得Enum的類型:
          Colors mycolor = (Colors)Enum.Parse(typeof(Colors),"red",true);
          (int)mycolor1=1
          mycolor1.GetTypeCode=Int32


          根據value獲得Enum的類型:
          Colors mycolor = (Colors)Enum.Parse(typeof(Colors),"1",true);
          mycolor2.ToString()=Red
          mycolor2.GetTypeCode=Int32


          遍歷枚舉內容
          foreach(string s in Enum.GetNames(typeof(Colors)))
          {
          //to do
          }


          Colors myOrange = (Colors)Enum.Parse(typeof(Colors), "Red, Blue,Yellow");
          The myOrange value has the combined entries of [myOrange.ToString()]=13


          Colors myOrange2 = (Colors)Enum.Parse(typeof(Colors), "Red, Blue");
          The myOrange2 value has the combined entries of [myOrange2.ToString()]=5
          posted on 2009-11-20 17:49 becket_zheng 閱讀(685) 評論(0)  編輯  收藏 所屬分類: C#
          <2009年11月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿

          隨筆分類(138)

          隨筆檔案(134)

          文章分類(77)

          文章檔案(109)

          email

          常去的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 湖北省| 泰和县| 昌邑市| 涿州市| 贡嘎县| 安福县| 山阳县| 海淀区| 保康县| 陇南市| 襄汾县| 巨鹿县| 启东市| 南京市| 大悟县| 吉安市| 兴文县| 随州市| 崇阳县| 阜新市| 涟水县| 延川县| 商水县| 同江市| 布尔津县| 吉木乃县| 佛坪县| 清镇市| 富裕县| 临沧市| 左权县| 都兰县| 鄂州市| 克拉玛依市| 丰都县| 讷河市| 卫辉市| 南丹县| 仲巴县| 昂仁县| 广汉市|