Contract.Assume Contract.Assume Contract.Assume Contract.Assume Method

Definition

Instructs code analysis tools to assume that a condition is true, even if it cannot be statically proven to always be true.

Overloads

Assume(Boolean) Assume(Boolean) Assume(Boolean) Assume(Boolean)

Instructs code analysis tools to assume that the specified condition is true, even if it cannot be statically proven to always be true.

Assume(Boolean, String) Assume(Boolean, String) Assume(Boolean, String) Assume(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.

Assume(Boolean) Assume(Boolean) Assume(Boolean) Assume(Boolean)

Instructs code analysis tools to assume that the specified condition is true, even if it cannot be statically proven to always be true.

public:
 static void Assume(bool condition);
[System.Diagnostics.Conditional("DEBUG")]
[System.Diagnostics.Conditional("CONTRACTS_FULL")]
public static void Assume (bool condition);
static member Assume : bool -> unit
Public Shared Sub Assume (condition As Boolean)
Parameters
condition
Boolean Boolean Boolean Boolean

The conditional expression to assume true.

Remarks

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

Assume(Boolean, String) Assume(Boolean, String) Assume(Boolean, String) Assume(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.

public:
 static void Assume(bool condition, System::String ^ userMessage);
[System.Diagnostics.Conditional("DEBUG")]
[System.Diagnostics.Conditional("CONTRACTS_FULL")]
public static void Assume (bool condition, string userMessage);
static member Assume : bool * string -> unit
Public Shared Sub Assume (condition As Boolean, userMessage As String)
Parameters
condition
Boolean Boolean Boolean Boolean

The conditional expression to assume true.

userMessage
String String String String

The message to post if the assumption fails.

Remarks

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.

Applies to