Assert Method (Boolean)
Collapse the table of content
Expand the table of content

Debug.Assert Method (Boolean)

[ 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 call stack if the condition is false.

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)

'Declaration
<ConditionalAttribute("DEBUG")> _
Public Shared Sub Assert ( _
	condition As Boolean _
)

Parameters

condition
Type: System.Boolean
The conditional expression to evaluate. If the condition is true, the call stack is not displayed.

Typically, the Assert method is used to identify logic errors during program development. Assert(Boolean) evaluates a specified condition. If the result is false, it sends diagnostics to the debugger.

The Assert(Boolean) overload outputs the call stack with file and line numbers for each line in the call stack.

The default behavior displays an Assert dialog box when the application runs in user-interface mode, and outputs the call stack to the debugger when in debug mode.

NoteNote:

The Assert method behaves differently in Windows Phone applications than it does in desktop applications. When an Assert occurs, 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.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft