首页 > 编程语言 > 详细

c#中Enum和String相互转换

时间:2015-02-01 20:29:10      阅读:237      评论:0      收藏:0      [点我收藏+]

枚举:

 public enum MonitorType
        {
            ManualMonitor ,//人工监测
            Tm30,//TM机器人监测
            Ls ,//拉载监测
            FiberBraggGrate,//光纤光栅
            LightMonitor,//微光监测
            Gps //GPS监测

        }

String转Enum:

MonitorType monitorType = (MonitorType)Enum.Parse(typeof(MonitorType), "Ls");

Enum转String:


String  str=MonitorType.Ls.toString();



c#中Enum和String相互转换

原文:http://blog.csdn.net/wj512416359/article/details/43373895

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!