CountBetween - Kalkwst/Risotto GitHub Wiki

Definition

Determines whether or not the number of elements in the sequence is between an inclusive range of lower and upper integer limits.

In this page

Overloads

Overload Description
CountBetween(int lower, int upper) Determine whether or not the number of elements is within a specified range

CountBetween(int lower, int upper)

Determines whether or not the number of elements in the sequence is between an inclusive range of lower and upper integer limits.

public static bool CountBetween<T>(this IEnumerable<T> source, int lower, int upper);

Type Parameters

TSource
The type of the elements of source.

Parameters

source IEnumerable <TSource>
A sequence of which to count the elements.

lowerInt32
The lower bound of which the number of elements must be.

upperInt32
The upper bound of which the number of elements must be.

Returns

Boolean
true if the number of elements in the sequence is between the lower and upper bounds, false otherwise.

Exceptions

ArgumentNullException
source is null

ArgumentOutOfRangeException
if lower is less than 0

-or-

upper is less than lower

Example

The following code example demonstrates how to use CountBetween(int lower, int upper) to determine whether the number of elements in a sequence is within bounds.

var source = new int[] { 1, 2, 3 };
source.CountBetween(2, 4);
//=> true

source.CountBetween(1, 2);
//=> false
⚠️ **GitHub.com Fallback** ⚠️