Sending Text to the Debug Output Window

The System.Diagnostics.Debug class provides a set of methods and properties that help debug code. The System.Diagnostics.Debug.Write and System.Diagnostics.Debug.WriteLine methods can be used to send text to the debug output window. The debug output window can be displayed by selecting View - Other Windows - Output in the Visual Studio .NET menu. The debug output can only be viewed in this window if the debugger is attached to the process that is writing to the output window.

The text displayed in the output window is sequential, so the text is displayed in the order it is received. Sending text to the output window is most useful for getting non-critical information. For example, to determine if Method1 is called before or after Method2, place a System.Diagnostics.Debug.WriteLine("Method1") at the beginning of Method1 and a System.Diagnostics.Debug.WriteLine("Method2") at the beginning of Method2. The method name that appears first indicates the method that is called first.

Send comments about this topic to Microsoft

Build date: 2/16/2009