I often run into a situation where I want to have a set of key/value pairs. Here’s a pseudo code idea:
DataSet MyRequestStatus
{
Accepted = "ACC",
Rejected = "REJ"
}
Usage:
InsertIntoTable(MyRequestStatus.Accepted.ToString())
I want to be able to use the friendly “MyRequestStatus.Accepted”, but I want the ToString() to return the cryptic “ACC”, NOT “Accepted”. Bonus points, implicit conversion rather than having to call ToString().
I haven’t found an obvious way to achieve this with Enums. What do you suggest?
1 Answer