Console.WriteLine() intended for console mode programs. A good feature of the Visual Studio hosting process is to display it in the Visual Studio output window when debugging for processes that do not have a console. This is very useful when debugging, but be careful that you must remove this code (or wrap it with #ifdef DEBUG ) when you are ready to create the Release assembly. Otherwise, this will add unnecessary overhead to your program. This makes it less ideal for debugging tracking.
Debug.WriteLine() generates trace information if you create conditional #defined using DEBUG . This is enabled by default in the Debug assembly. If the output ends, you can configure it in the app.exe.config file. If this configuration is not overridden, .NET automatically provides an instance of the DefaultTraceListener class. It sends the text Debug.WriteLine() using the Windows API function OutputDebugString() for the debugger. The Visual Studio debugger does this in the output window, as does Console.WriteLine() .
The Debug.WriteLine() advantage of Debug.WriteLine() is that it does not generate overhead in the Release assembly, calls are effectively deleted. However, it does not support compound formatting, for this you will need String.Format() . To track debugging, the Debug class should be your choice.
Hans Passant Jun 10 2018-10-10T00: 00Z
source share