Name
Debug Class
Namespace
System.Diagnostics
Createable
No
Description
The Debug object is used to send messages to the
Output window (formerly called the Immediate window). The
Debug object can also send output to other
targets, such as text files, referred to as
listeners. See the
Debug.Listeners Property entry.
The Debug class also allows you to check program logic with
assertions.
Because the Debug class’ members are shared, you do
not need to instantiate the Debug object before
accessing its members. The following code fragment, for instance,
illustrates a call to the Debug
object’s WriteLine method:
Debug.WriteLine(intCount & " iteration through the loop")
Debug class members marked with an plus sign (+) are discussed in detail in their own entries.
Public Shared Properties
| AutoFlush + |
| IndentLevel + |
| IndentSize + |
| Listeners + |
Public Shared Methods
| Assert + |
| Close + |
| Fail |
| Flush + |
| Indent + |
| Unindent + |
| Write + |
| WriteIf + |
| WriteLine + |
| WriteLineIf + |
VB.NET/VB 6 Differences
The VB 6 Debug object has only two methods, Assert
and Print. The VB.NET Assert method is similar to the VB 6 method,
except that the latter displays a message if an expression is
False, while the former suspends program
execution. In VB.NET, the VB 6 Print method is gone, replaced by the
Write, WriteIf, WriteLine, and WriteLineIf methods.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access