Q:

convert uint to const name

I have some constant error codes in a class:
 public class EDSDK
 {
    public const uint EDS_ERR_UNIMPLEMENTED = 0x00000001;  
    public const uint EDS_ERR_INTERNAL_ERROR = 0x00000002;
    public const uint EDS_ERR_MEM_ALLOC_FAILED = 0x00000003;

}

How can I get the const name from an (hex encoded) value? 

A:

If you use enum, it can be done with Enum. ToString():
public enum EDSDK
{
    EDS_ERR_UNIMPLEMENTED = 0x00000001,
    EDS_ERR_INTERNAL_ERROR = 0x00000002,
    EDS_ERR_MEM_ALLOC_FAILED = 0x00000003
}

EDSDK status = (EDSDK)0x00000001;
string statusString = status. ToString();

