Share via


Contract.Assert Method (Boolean)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Checks for a condition; if the condition is false, follows the escalation policy set for the analyzer.

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

Syntax

'Declaration
<ConditionalAttribute("DEBUG")> _
<ConditionalAttribute("CONTRACTS_FULL")> _
Public Shared Sub Assert ( _
    condition As Boolean _
)
[ConditionalAttribute("DEBUG")]
[ConditionalAttribute("CONTRACTS_FULL")]
public static void Assert(
    bool condition
)

Parameters

Remarks

The default escalation policy is to notify the attached debugger about a contract failure or to display an Assert dialog box if a debugger is not attached. Optionally, the analyzer can be instructed to throw an exception.

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.