c#中Enum跟String相互转换
c#中Enum和String相互转换
枚举:
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();