如何定义一个全局常量在C#中(如DEBUG)常量、全局、定义、DEBUG

由网友(久念成瘾)分享简介:我想不同的编译项目,根据的#define定义的常数,是这样的:I want to compile a project differently, according to a constant defined by #define, like this:#define USE_COMPONENT_X#if USE_C...

我想不同的编译项目,根据的#define定义的常数,是这样的:

I want to compile a project differently, according to a constant defined by #define, like this:

#define USE_COMPONENT_X

#if USE_COMPONENT_X
...

#endif

和我能做到这一点在C#。但是,当我去同一个项目的另一个文件,这个常量没有定义。我能以某种方式定义常量的所有项目,如DEBUG被定义呢?

and I can do that in C#. But when I go to another file in the same project, this constant is not defined. Can I in some way define a constant to all the project, like DEBUG is defined so?

推荐答案

您可以添加/定义编译器开关。

You can add the /define compiler switch.

打开项目的属性页对话框。 单击配置属性文件夹。 点击生成属性页。 修改条件编译常量属性。
阅读全文

相关推荐

最新文章