C# Compiler Directives

后端 未结 4 1494
温柔的废话
温柔的废话 2021-01-18 02:13

I’m looking at some C# code, and have come across the following statement:

#if DEBUG
    // Do something here
#else
    // Do something else
#endif
         


        
4条回答
  •  鱼传尺愫
    2021-01-18 02:21

    It is set with the #define directive or in the compiler settings. It is common for DEBUG to be defined in debug releases, so you could conditionally compile some code like in your example.

    You can read more about it on MSDN.

提交回复
热议问题