Determine the name of a constant based on the value

后端 未结 7 926
广开言路
广开言路 2021-01-05 22:07

Is there a way of determining the name of a constant from a given value?

For example, given the following:

public const uint ERR_OK = 0x00000000;

Ho

相关标签:
7条回答
  • 2021-01-05 22:46

    I suggest you use an enum to represent your constant.

    Or

    string ReturnConstant(uint val)
    {
         if(val == 0x00000000)
           return "ERR_OK";
         else
           return null;
    }
    
    0 讨论(0)
提交回复
热议问题