星空网 > 软件开发 > ASP.net

枚举类型和各种类型之间转换

 //声明枚举      public enum Sesons      {        春,        夏,        秋,        冬      } static void Main(string[] args)      {        Sesons s = Sesons.春;                string str="0";        //枚举类型可以直接转换成int类型int s=(int)Sesons.春int cun=(int)Sesons.春;;//结果等于cun=0        

枚举类型转字符串string类型

  //声明枚举      public enum Sesons      {        春,        夏,        秋,        冬      }      //声明枚举      public enum QQstate      {        OnLine,        OffLine,        leave,        QMe      }      static void Main(string[] args)      {        Sesons s = Sesons.春;               QQstate q = QQstate.OnLine;        string str="0";        //枚举类型可以直接转换成int类型int s=(int)QQstate.春        //将字符串转换成枚举Enum.Parse,typeof(),获取对象类型        QQstate qzx=(QQstate)Enum.Parse(typeof(QQstate),str);        Console.WriteLine(qzx);        Console.ReadKey();      }

 




原标题:枚举类型和各种类型之间转换

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

JOOM第四季度数据分析和选品方向:https://www.ikjzd.com/articles/9422
亚马逊自有品牌销售报告:女装销售表现不佳!:https://www.ikjzd.com/articles/94220
进口退货新模式启动!速度快,成本低!:https://www.ikjzd.com/articles/94221
亚马逊账号来之不易,账号信息且改且珍惜!:https://www.ikjzd.com/articles/94222
A9算法解析:打造高品质亚马逊图片最全攻略!:https://www.ikjzd.com/articles/94224
分享10款出口跨境电商视频营销工具!:https://www.ikjzd.com/articles/94225
去日本入住酒店,东西随意用却有一个特殊“要:https://www.vstour.cn/a/411241.html
中国有哪些著名的酒店品牌。:https://www.vstour.cn/a/411242.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流