且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#中的if / then调试VS发布指令

更新时间:2021-09-14 01:45:12

在您的code删除将#define DEBUG 。在构建配置中设置preprocessors针对特定版本(DEBUG / _DEBUG应VS定义的话)。

Remove the #define DEBUG in your code. Set preprocessors in the build configuration for that specific build (DEBUG/_DEBUG should be defined in VS already).

它打印模式=调试的原因是因为你的的#define 键,然后跳过 ELIF

The reason it prints "Mode=Debug" is because of your #define and then skips the elif.

此外,检查正确的方法是:

Also, the right way to check is:

#if DEBUG
    Console.WriteLine("Mode=Debug"); 
#else
    Console.WriteLine("Mode=Release"); 
#endif

不检查发布