Pre-Processor directives in C#

风格不统一 提交于 2019-12-11 13:32:32

问题


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

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?


回答1:


Any chance you have DEBUG defined for both Debug and Release configurations?




回答2:


Do you have a "#define DEBUG" line ? That sets DEBUG to true always.



来源:https://stackoverflow.com/questions/637061/pre-processor-directives-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!