#if Not Debug in c#?
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)
Just so you are familiar with what is going on here, #if
is a pre-processing expression, and DEBUG
is a conditional compilation symbol. Here's an MSDN article for a more in-depth explanation.
By default, when in Debug configuration, Visual Studio will check the Define DEBUG constant option under the project's Build properties. This goes for both C# and VB.NET. If you want to get crazy you can define new build configurations and define your own Conditional compilation symbols. The typical example when you see this though is:
#if DEBUG
//Write to the console
#else
//write to a file
#endif