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

后端 未结 7 920
情歌与酒
情歌与酒 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:47

    Check How to: Define Constants in C# on MSDN:

    In C# the #define preprocessor directive cannot be used to define constants in the way that is typically used in C and C++.

提交回复
热议问题