Use StringBuilder to create your own output strings, rather than concatenating each value.
And you can create your own custom debugger class (MyDbg) that contains the WriteLine element, the contents of which you can surround with compilation commands. It will not fully compile the debugging code, but will turn you into calls to MyDbg.WriteLine into no-ops.
Here's a quick sketch of the class:
using System; using System.Text ; public static class MyDbg { public static void WriteLine(string str)
OR
[Conditional("DEBUG")] public static class MyDbg { public static void WriteLine(string str)
You would change it to, of course, satisfy your own needs. And instead of creating a separate class, you can create a member method if #if DEBUG / # endif is built-in to display your own state in the debugger.
source share