Referring to the "Configuration Manager" under the Build menu,
Is there a way to comment my C# code so that the commented out code does not compile while the solution is in Debug mode, but would compile if I changed it to Release mode?
Why do I want this? The reason that I want to have code that will be compiled in Release mode, but not in Debug, is that I've got some code that will not work from my development PC (code that sends emails from my host, etc.).
Instead of having to run back through my code and uncomment lines before publishing, I'd like that to be automatic.
You may be looking for something like this:
#if DEBUG
Console.WriteLine("Debug Mode");
#else
Console.WriteLine("Release Mode");
#endif
If you only care about release mode, you can use:
#if !DEBUG
Console.WriteLine("Release Mode");
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With