locked
c# Preprocessor Directives vs the Conditional Attribute RRS feed

  • General discussion

  • Hello,
    I would just like to get some different thoughts on using the C# Preprocessor Directives such as #if DEBUG versus using the Conditional attribute [Conditional ("DEBUG")].
    Thursday, March 18, 2010 4:05 PM

All replies

  • If you give the Conditional debug attribute, the method would still be a part of the assembly, but not loaded when DEBUG is not defined. In the case of #if and #endif, the method would not be visible in the release assembly itself.
    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    blog.ganeshzone.net
    Thursday, March 18, 2010 4:24 PM
  • How would you write the equivalent to #if !DEBUG with a Conditional attribute?
    Thursday, March 18, 2010 4:28 PM
  • How would you write the equivalent to #if !DEBUG with a Conditional attribute?

    You need to define another preprocessor symbol e.g. RELEASE and use that instead of !DEBUG.

    Matt
    Thursday, March 18, 2010 4:40 PM