PrimitiveExtensionsEnforceT Method (Boolean, String) |
Confirms that a condition is true. Raise an exception of type T if it is not.
Namespace: Bio.UtilAssembly: Bio.Core (in Bio.Core.dll) Version: 2.0.0.1 (2.0.0.1)
Syntax public static bool Enforce<T>(
this bool condition,
string message
)
where T : new(), Exception
<ExtensionAttribute>
Public Shared Function Enforce(Of T As {New, Exception}) (
condition As Boolean,
message As String
) As Boolean
public:
[ExtensionAttribute]
generic<typename T>
where T : gcnew(), Exception
static bool Enforce(
bool condition,
String^ message
)
[<ExtensionAttribute>]
static member Enforce :
condition : bool *
message : string -> bool when 'T : new() and Exception
Parameters
- condition
- Type: SystemBoolean
The condition to check - message
- Type: SystemString
A message for the exception
Type Parameters
- T
- The type of exception that will be raised.
Return Value
Type:
Boolean[Missing <returns> documentation for "M:Bio.Util.PrimitiveExtensions.Enforce``1(System.Boolean,System.String)"]
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
Boolean. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Remarks
Warning: The message with be evaluated even if the condition is true, so don't make it's calculation slow.
Avoid this with the "messageFunction" version.
See Also