Debug.Assert Method (Boolean, String, String, Object())
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Checks for a condition and outputs the message and the call stack if the condition is false.
Assembly: System (in System.dll)
'Declaration <ConditionalAttribute("DEBUG")> _ Public Shared Sub Assert ( _ condition As Boolean, _ message As String, _ detailMessageFormat As String, _ ParamArray args As Object() _ )
Parameters
- condition
- Type: System.Boolean
The conditional expression to evaluate. If the condition is true, the specified message and the call stack are not displayed.
- message
- Type: System.String
A message to display.
- detailMessageFormat
- Type: System.String
A composite format string that contains text intermixed with zero or more format items, which correspond to objects in the args array.
- args
- Type:
System.Object
()
An object array that contains zero or more objects to format.
Typically, the Assert method is used to identify logic errors during program development. Assert evaluates a specified condition. If the result is false, it sends diagnostics to the debugger.
The Assert(Boolean, String, String, Object()) overload displays a message with inserted format items that you specify in an argument array.
The default behavior displays an Assert dialog box when the application runs in user-interface mode, and outputs the messages to the debugger when in debug mode.
Note: |
|---|
The Assert method behaves differently in Windows Phone applications than it does in desktop applications. When an Assert occurs in Windows, a dialog box is displayed with two options, OK and Cancel. Cancel causes the debugger to break at the Assert statement, OK causes it to continue. If a debugger is not currently attached, you may attach one before you close the dialog box. |
Note: