#if (DEBUG) VS System.Diagnostics.Debugger.IsAttached

前端 未结 6 856
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 11:52

What is different between using #if (DEBUG) and System.Diagnostics.Debugger.IsAttached in visual studio? Are there cases of the DEBUG

6条回答
  •  悲哀的现实
    2020-12-24 12:22

    #if DEBUG is a compile-time check, meaning the code it surrounds will only be included in the output assembly if the DEBUG preprocessor symbol is defined. Debugger.IsAttached is a runtime check, so the debugging code still gets included in the assembly, but only executes if a debugger is attached to the process.

提交回复
热议问题