Click here to Skip to main content
15,891,248 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

(C#) Determining whether the current build mode is Debug or Release

Rate me:
Please Sign up or sign in to vote.
3.85/5 (5 votes)
29 Jan 2012CPOL 18.6K   6
You can make it a bit shorter: public virtual bool IsDebug { get { #if (DEBUG) return true; #else return false; #endif } }Thanks for sharing,
You can make it a bit shorter:
C#
public virtual bool IsDebug
{
    get {
    #if (DEBUG)
        return true;
    #else
        return false;
    #endif
    }
}



Thanks for sharing,

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Israel Israel
Pablo writes code for a living, in C++, C#, and SQL.

To make all that work easier, he uses some C++ libraries: STL, ATL & WTL (to write Windows applications), and code generation.

Pablo was born in 1963, got married in 1998, and is the proud father of two wonderful girls.

Favorite quotes:
"Accident: An inevitable occurrence due to the action of immutable natural laws." (Ambrose Bierce, "The Devil's Dictionary", published in several newspapers between 1881 and 1906).
"You are to act in the light of experience as guided by intelligence" (Rex Stout, "In the Best Families", 1950).

Comments and Discussions

 
GeneralReason for my vote of 2 irrelevant, the bad thing is not the... Pin
johannesnestler1-Feb-12 4:28
johannesnestler1-Feb-12 4:28 
GeneralReason for my vote of 1 This is not an alternative. Removing... Pin
Pankaj Chamria30-Jan-12 3:08
Pankaj Chamria30-Jan-12 3:08 
GeneralReason for my vote of 1 It makes your life harder when debug... Pin
filoteanuadrian30-Jan-12 0:01
filoteanuadrian30-Jan-12 0:01 
GeneralRe: How so? I just activate debug logging, then run one of the a... Pin
SoftwareMonkeys30-Jan-12 10:22
SoftwareMonkeys30-Jan-12 10:22 
GeneralReason for my vote of 5 It's classic pattern :-) Pin
Member 13192329-Jan-12 23:06
Member 13192329-Jan-12 23:06 
General@Pablo - True but doing it directly like that makes it trick... Pin
SoftwareMonkeys29-Jan-12 22:34
SoftwareMonkeys29-Jan-12 22:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.