How to define constants in Visual C# like #define in C?

后端 未结 7 900
情歌与酒
情歌与酒 2020-12-29 18:53

In C you can define constants like this

#define NUMBER 9

so that wherever NUMBER appears in the program it is replaced with 9. But Visual

7条回答
  •  天涯浪人
    2020-12-29 19:42

    public const int NUMBER = 9;
    

    You'd need to put it in a class somewhere, and the usage would be ClassName.NUMBER

提交回复
热议问题