C# how can I use #if to have different compile result for debug and release?

前端 未结 3 468
暗喜
暗喜 2021-02-10 05:26

In C++ we can use #ifdef to eliminate some debug statements when we release. C# is different from C++ in preprocessor. Can I still get the same result useing C# #if. We want to

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-10 05:50

    Use something like:

    #if DEBUG
    
    System.Console.WriteLine("This is debug line");
    
    #endif
    

提交回复
热议问题