ObjectExtensionsThrowIfNotInRangeT Method
Throws an ArgumentOutOfRangeException if the
source value is not within the specified range.
Namespace: DevCase.Extensions.ObjectExtensionsAssembly: 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
<ExtensionAttribute>
<EditorBrowsableAttribute(EditorBrowsableState.Always)>
Public Shared Sub ThrowIfNotInRange(Of T As {Object, IComparable(Of T), IConvertible, IEquatable(Of T), IFormattable}) (
value As T,
min As T,
max As T,
Optional message As String = Nothing,
Optional paramName As String = Nothing
)
Dim value As T
Dim min As T
Dim max As T
Dim message As String
Dim paramName As String
value.ThrowIfNotInRange(min, max,
message, paramName)
public:
[ExtensionAttribute]
[EditorBrowsableAttribute(EditorBrowsableState::Always)]
generic<typename T>
where T : Object, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
static void ThrowIfNotInRange(
T value,
T min,
T max,
String^ message = nullptr,
String^ paramName = nullptr
)
[<ExtensionAttribute>]
[<EditorBrowsableAttribute(EditorBrowsableState.Always)>]
static member ThrowIfNotInRange :
value : 'T *
min : 'T *
max : 'T *
?message : string *
?paramName : string
(* Defaults:
let _message = defaultArg message null
let _paramName = defaultArg paramName null
*)
-> unit when 'T : Object and IComparable<'T> and IConvertible and IEquatable<'T> and IFormattable
No code example is currently available or this language may not be supported.
- 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.
- T
-
The type of value to evaluate.
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).
This is a code example.
No code example is currently available or this language may not be supported.
Dim value As Integer = 10
' value.ThrowIfNotInRange(min:=1, max:=9)
value.ThrowIfNotInRange(min:=1, max:=9, message:="Value is not within the allowed range.", paramName:=NameOf(value))
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
|
ArgumentOutOfRangeException
|
Thrown when the value is not within the specified range.
|