How to get the underlying value of an enum

I have the following enum declared:

 public enum TransactionTypeCode { Shipment = 'S', Receipt = 'R' }

How do I get the value ‘S’ from a TransactionTypeCode.Shipment or ‘R’ from TransactionTypeCode.Receipt ?

Simply doing TransactionTypeCode.ToString() gives a string of the Enum name “Shipment” or “Receipt” so it doesn’t cut the mustard.


Marking this as not correct, but I can’t delete it.

Try this:

string value = (string)TransactionTypeCode.Shipment;