VAAA
VAAA

Reputation: 15039

Get enum char value

I have an Enum:

 public enum SensorType
    {

        Normal ='N',

        Lunch ='C',

        ALL
    }

In my function:

private void GetData(SensorType type){

    var charValue = type.ToString(); // here I want to get the char value, not the string.
}

I want to get "N", or "C" etc. any clue?

Thanks

Upvotes: 1

Views: 1987

Answers (1)

paulsm4
paulsm4

Reputation: 121669

Just cast the value:

char charValue = (char)type;

Upvotes: 6

Related Questions