ObjectExtensionsThrowIfNotInRangeT Method

Throws an ArgumentOutOfRangeException if the source value is not within the specified range.

Definition

Namespace: DevCase.Extensions.ObjectExtensions
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[EditorBrowsableAttribute(EditorBrowsableState.Always)]
public static void ThrowIfNotInRange<T>(
	this T value,
	T min,
	T max,
	string message = null,
	string paramName = null
)
where T : Object, IComparable<T>, IConvertible, IEquatable<T>, IFormattable

Parameters

value  T
The value to evaluate.
min  T
The minimum allowed value (inclusive).
max  T
The maximum allowed value (inclusive).
message  String  (Optional)
Optionally, the custom error message for the ArgumentOutOfRangeException.
paramName  String  (Optional)
Optionally, the name of the parameter that caused the ArgumentOutOfRangeException.

Type Parameters

T
The type of value to evaluate.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type T. 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).

Example

This is a code example.
C#
No code example is currently available or this language may not be supported.

Exceptions

ArgumentOutOfRangeException Thrown when the value is not within the specified range.

See Also