When to use preprocessor directives in .net?

后端 未结 7 1640
情话喂你
情话喂你 2020-12-15 18:01

I think this is a simple question so I assume I\'m missing something obvious. I don\'t really ever use preprocessor directives but I was looking at someone\'s code which di

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 18:05

    I would like to give one example where I have used preprocessor directive in my project.

    My program creates lot of intermediate files on disk. I used #DEBUG directive to delete those files only if my project is in release mode, otherwise I keep those file so that we can view those intermediate files and determine whats happening inside.

    When my app is working on production server, I build project in release mode so those files are deleted after processing is complete.

    #if (DEBUG==false)
        deleteTempFiles()
    #endif
    

提交回复
热议问题