C# 获取枚举字符值
我有一个枚举:C# 获取枚举字符值,c#,enums,C#,Enums,我有一个枚举: public enum SensorType { Normal ='N', Lunch ='C', ALL } 在我的职责中: private void GetData(SensorType type){ var charValue = type.ToString(); // here I want to get the char value, not the string. } 我想得到N或C
public enum SensorType
{
Normal ='N',
Lunch ='C',
ALL
}
在我的职责中:
private void GetData(SensorType type){
var charValue = type.ToString(); // here I want to get the char value, not the string.
}
我想得到N或C等,有线索吗
谢谢只需设定价值:
char charValue=chartype 只需转换值:
char charValue=chartype 这里已经回答了这里已经回答了