In .NET when debugging code, is there any difference between using Debug.Print
and Console.WriteLine
?

- 30,738
- 21
- 105
- 131

- 3,528
- 4
- 28
- 40
-
1Debug.Print prints to the output and used for tracing! Console.Writeline actually writes the output to the console. – Nilesh Sep 18 '13 at 11:59
3 Answers
Yes, Console.WriteLine
Writes the specified data, followed by the current line terminator, to the standard output stream.
Whereas Debug.Print
Writes a message followed by a line terminator to the trace listeners in the Listeners collection.
Where Listeners
is a List in Debug
.
A better example might be with a picture. Note that Console.WriteLine
ends up in the Console and the Debug.Print
ends up in the Output window for Visual Studio

- 30,738
- 21
- 105
- 131

- 11,485
- 9
- 66
- 102
However, the big difference is in concept rather than functionality. The Console.WriteLine is, as I mentioned, meant to be the output channel in console applications. Debug.Print is there to an aid to you, the programmer.
The debug class enables you to write debug outputs that the users can't see, and in addition provides tools to check your code through deliberate output.

- 30,738
- 21
- 105
- 131

- 5,754
- 6
- 26
- 56
Debug writes the message to the Output > Debug. Console.WriteLine writes a message to standard output (console).

- 30,738
- 21
- 105
- 131

- 2,332
- 1
- 22
- 48
-
-
@PeterMortensen I think he means to the Debug section of the Output window. In addition to Debug, you can choose Build or Build Order from a dropdownlist. – TylerH Feb 02 '18 at 19:55