C#中的预处理器指令 [英] Pre-Processor directives in C#
问题描述
我似乎在使用C#中的预处理程序指令时遇到麻烦。我已经创建了一个Visual Studio 2008 C#Win Forms应用程序。我添加以下内容:
I seem to be having trouble with preprocessor directives in C#. I've created a Visual Studio 2008 C# win forms app. I add this:
#if (DEBUG)
textBox1.Text = "in debug mode";
#else
textBox1.Text = "in release mode";
#endif
当我在调试中运行时,我看到了预期的处于调试模式 。但是,当我切换到发布,编译并运行.exe时,仍看到处于调试模式文本。在我的项目属性中,我检查了定义 DEBUG
常量。我什至为上述代码获得了正确的颜色编码语法。
And when I run in debug I see the expected "in debug mode". However when I switch to Release, compile, and run the .exe, I still see the "in debug mode" text. In my project properties I have Define DEBUG
constant checked. I even get the correct color-coded syntax for the code above. What gives?
推荐答案
是否有机会为调试和发布配置定义了DEBUG?
Any chance you have DEBUG defined for both Debug and Release configurations?
这篇关于C#中的预处理器指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!