#if Not Debug in c#?

前端 未结 5 1338
生来不讨喜
生来不讨喜 2020-12-24 11:07

I have the line in vb code:

#if Not Debug

which I must convert, and I don\'t see it in c#?

Is there something equivalent to it,

5条回答
  •  臣服心动
    2020-12-24 12:06

    You would need to use:

    #if !DEBUG
        // Your code here
    #endif
    

    Or, if your symbol is actually Debug

    #if !Debug
        // Your code here
    #endif
    

    From the documentation, you can effectively treat DEBUG as a boolean. So you can do complex tests like:

    #if !DEBUG || (DEBUG && SOMETHING)
    

提交回复
热议问题