How can I create an enum using numbers?

前端 未结 7 1335
野趣味
野趣味 2021-01-11 11:11

Is it possible to make an enum using just numbers in C#? In my program I have a variable, Gain, that can only be set to 1, 2, 4, and 8. I am using a propertygrid control to

7条回答
  •  伪装坚强ぢ
    2021-01-11 11:54

    If I understood the original question correctly, the answer may be this:

    You can get numbers listed in an enum in the inspector by simply using an underscore prefix, e.g:

    public enum MyNumbers{ _1, _2, _3, _4 };
    public MyNumbers myNumbers;
    

    Hope this is helps!

提交回复
热议问题