Hey everyone.
I've got a few segments of code (usually stopwatch objects) I want to run only during debug. When the program is built for release, these lines would merely slow the program down. Is there a way to manage this in C# express?
Printable View
Hey everyone.
I've got a few segments of code (usually stopwatch objects) I want to run only during debug. When the program is built for release, these lines would merely slow the program down. Is there a way to manage this in C# express?
Note that the extra code is NOT executable C# code. It is a directive to the preprocessor so the compiler never even sees it. As such it can go anywhere you like. It can even be used in ways that may look like they'd create compilation errors but, because some of the code is never compiled they don't, e.g.CSharp Code:
#if DEBUG // Code here will only be compiled into a Debug build. #else // Code here will only be compiled into a Release build. #endifCSharp Code:
#if DEBUG public void SomeMethod(string someValue) { MessageBox.Show(someValue); #else public void SomeMethod() { #endif // Do something here. }
Awsome! I'd used preprocessor code before, but couldn't seem to track down the right combination of it to get debug only stuff working.
T'anks!