Is it correct to use such a code?

#define LOGGING #if LOGGING using log4net; using log4net.Config; #endif 

    2 answers 2

    In terms of compilability, yes, correctly: http://ideone.com/b7jxl0

      Incorrectly, since the directive is declared, the value is not specified, but it is this value that is checked in if LOGGING. It should be replaced with #ifdef LOGGING, or #define LOGGING 1

      • Well, the usual pieces of code work, the presence considers it true :) Podkskazhite, and from the code I can use, the value of this directive? - alex91
      • You can not change, these directives are used only at the compilation stage. - artkil
      • one
        You are not confused with C ++? In C # there is no #ifdef . - VladD
      • one
        > Podkskazhite, and from isoplnyaem code I can the value of this directive? You have a misconception about directives, read [here] [1], for example. [1]: en.wikipedia.org/wiki/… - nitrocaster