Provides a set of methods and properties that help debug your code. This class cannot be inherited.
Assembly: System (in System.dll)
'Declaration Public NotInheritable Class Debug
public static class Debug
The Debug type exposes the following members.
|Assert(Boolean)||Checks for a condition and outputs the call stack if the condition is false.|
|Assert(Boolean, String)||Checks for a condition and displays a specified message if the condition is false.|
|Assert(Boolean, String, String)||Checks for a condition and displays two specified messages if the condition is false.|
|Assert(Boolean, String, String, array<Object)||Checks for a condition and outputs the message and the call stack if the condition is false.|
|WriteLine(Object)||Writes the value of a specified object's ToString method to the debugger by using the OutputDebugString function.|
|WriteLine(String)||Writes a specified message followed by a line terminator to the debugger by using the OutputDebugString function.|
|WriteLine(String, array<Object)||Writes a formatted string followed by a line terminator to the debugger by using the OutputDebugString function.|
If you use methods in the Debug class to display debugging information and check your logic with assertions, you can make your code more robust without affecting the performance and code size of your shipping product.
This class provides methods for displaying an Assert dialog box, and for emitting an assertion that will always fail. This class provides write methods in the following variations: WriteLine(Object), WriteLine(String), and WriteLine(String, array<Object).
The debugging methods in the Debug class behave differently in Silverlight-based applications than they do in desktop applications. There is no Listeners collection to specify the destination for debug output. In Windows, the .NET Framework for Silverlight sends debugging information to the OutputDebugString function and to the debugger, if one is attached. The Visual Studio debugger displays the information in the Output window. If a debugger is not attached, the output from OutputDebugString can be viewed by using a debug viewer. The Apple Macintosh OS X does not have an OutputDebugString function. Therefore, managed debugging can be done only through remote debugging on a Windows computer by using a Visual Studio plug-in.
To define the "DEBUG" conditional compilation symbol in C#, add the /d:DEBUG option to the compiler command line when you compile your code or add #define DEBUG to the top of your file. In Visual Basic, add the /d:DEBUG=True option to the compiler command line or add #Const DEBUG=True to the file.
In Visual Studio projects, by default, the "DEBUG" conditional compilation symbol is defined for debug builds, and the "TRACE" symbol is defined for both debug and release builds. For information on how to disable this behavior, see the Visual Studio documentation.
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
Supported in: Xbox 360, Windows Phone OS 7.0
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
This type is thread safe.