Reputation: 53396
I have a database which needs a status column updating to a single char status code ('E' or 'U').
I'd like to use an enum for updating this field through my API to ensure the possible values are restricted correctly. Obviously enums can't be of char type. What might be be a good alternative method?
And no, I can't change the database schema :)
Upvotes: 0
Views: 331
Reputation: 117250
byte
- if you have char
ushort
- if you have nchar
Both can be cast to the underlying integer, and then cast to char
(C#).
Upvotes: 1
Reputation: 39500
You can assign chars to enum members.
Does this help:
enum Status
{
Empty = 'E',
Updated = 'U'
}
void Main()
{
Status status = Status.Empty;
Console.WriteLine("{0}: {1}", status, (char)status);
}
Upvotes: 4