Disable or remove all Console#WriteLine calls?

Here's a even quicker quick fix I implemented.

...
static int Main(String[] args)
{
...
#if !DEBUG
    Console.SetOut(TextWriter.Null);
    Console.SetError(TextWriter.Null);
#endif
...
}

HTH


Maybe Find&Replace function in any code editor? For example find all

Console.WriteLine 

and replace with

//Console.WriteLine

If they are non-essential (logging) then you should have used System.Diagnostics.Debug.Print() to start with.

Luckily WriteLine() is compatible with Debug.Print() so that's an easy S&R. And fix some usings maybe.

Replacing Console.Write() might be a little trickier.

To be complete: The Debug.Print() statements can be turned on/off with a checkbox in project|Properties.

Tags:

C#

.Net