Contract::Assume Method (Boolean, String^)

 

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)

public:
[ConditionalAttribute("DEBUG")]
[ConditionalAttribute("CONTRACTS_FULL")]
static void Assume(
	bool condition,
	String^ userMessage
)

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: