Contract.Assume Method (Boolean, String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Instructs code analysis tools to assume that a condition is true, even if it cannot be statically proven to always be true, and displays a message if the assumption fails.

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

<ConditionalAttribute("DEBUG")>
<ConditionalAttribute("CONTRACTS_FULL")>
Public Shared Sub Assume (
	condition As Boolean,
	userMessage As String
)

Parameters

condition
Type: System.Boolean

The conditional expression to assume true.

userMessage
Type: System.String

The message to post if the assumption fails.

If userMessage is not a constant string literal, the contract may not be understood by tools.

At run time, using this method is equivalent to using the Assert(Boolean, String) method.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show: