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)

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)

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)

Source:
Contracts.cs
Source:
Contracts.cs
Source:
Contracts.cs

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);
[<System.Diagnostics.Conditional("DEBUG")>]
[<System.Diagnostics.Conditional("CONTRACTS_FULL")>]
static member Assume : bool -> unit
Public Shared Sub Assume (condition As Boolean)

Parameters

condition
Boolean

The conditional expression to assume true.

Attributes

Remarks

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

Applies to

Assume(Boolean, String)

Source:
Contracts.cs
Source:
Contracts.cs
Source:
Contracts.cs

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);
[System.Diagnostics.Conditional("DEBUG")]
[System.Diagnostics.Conditional("CONTRACTS_FULL")]
public static void Assume (bool condition, string? userMessage);
[<System.Diagnostics.Conditional("DEBUG")>]
[<System.Diagnostics.Conditional("CONTRACTS_FULL")>]
static member Assume : bool * string -> unit
Public Shared Sub Assume (condition As Boolean, userMessage As String)

Parameters

condition
Boolean

The conditional expression to assume true.

userMessage
String

The message to post if the assumption fails.

Attributes

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