I have an enum
public enum BookType
{
Old = 'O',
New = 'N',
All = 'B'
}
What I need to do is get the value of the char in the enum. For example if the enum is set to:
BookType bt = BookType.New
I need to get the value of new “N”
string val = (???)bt;
I need val = N
What is the best way to do this? If it was an int easy, just cast to int.
Thanks.
The values associated with your
enumare stillints, you’ve just set using a character literal. If you want to recover this value as a string, you can cast the enum value to acharand then convert that to a string: