How to get the underlying value of an enum Code Answer

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;

Related Posts

© No Copyrights, All Questions are retrived from public domain.
Tutorial Guruji