How to find whether it is in debug mode or release mode? Are there any other ways to find it?
#if(DEBUG)
{
Console.WriteLine("Debug mode");
//Or Things to do in debug mode
}
#else
{
Console.WriteLine("Release mode");
//Or Things to do in Release mode- May be to change the text, image
}
#endif
No that's the only way, but you need to have the syntax and capitalization correct. You can also check whether the debugger is attached. Here is the correct syntax:
#if DEBUG
Console.Writeline("debug");
#else
Console.Writeline("release");
#endif
// You can also check if a debugger is attached, which can happen in either debug or release
if (Debugger.IsAttached)
Console.WriteLine("debugger attached");
You could try using System.Diagnostics:
if (Debugger.IsAttached) {...
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.