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 閱讀(686) 評論(0)  編輯  收藏 所屬分類: C#
          <2009年11月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿

          隨筆分類(138)

          隨筆檔案(134)

          文章分類(77)

          文章檔案(109)

          email

          常去的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 喜德县| 定边县| 财经| 怀柔区| 隆安县| 乐平市| 阳江市| 玛沁县| 花莲市| 长海县| 敖汉旗| 灯塔市| 印江| 澄城县| 理塘县| 株洲县| 讷河市| 寿阳县| 达孜县| 扶沟县| 乌兰察布市| 黄平县| 民权县| 寿阳县| 丹棱县| 石景山区| 大方县| 桦南县| 南澳县| 留坝县| 东宁县| 海阳市| 马公市| 河北省| 上饶县| 得荣县| 大理市| 玉林市| 拉萨市| 柳州市| 潜江市|