No, this is the only way, but you need the correct syntax and capitalization. You can also check if the debugger is connected. Here is the correct syntax:
Console.Writeline("debug");
Console.Writeline("release");
// You can also check if a debugger is attached, which can happen in either debug or release
if (Debugger.IsAttached)
Console.WriteLine("debugger attached");
source
share