AtMost - Kalkwst/Risotto GitHub Wiki

Definition

Checks whether or not the number of elements in the sequence is less than or equal to the given threshold.

In this page

Overloads

Overload Description
AtMost(int threshold) Determines whether the number of elements in the sequence is less than or equal to the provided threshold.

AtMost(int threshold)

Determines whether the number of elements in the sequence is less than or equal to the provided threshold.

public static bool AtMost<TSource>(this IEnumerable<TSource> source, int threshold);

Type Parameters

TSource
The type of the elements of source.

Parameters

source IEnumerable <TSource>
A sequence that contains elements to be counted.

threshold
The maximum number of elements, the sequence must have.

Returns

Boolean

true the elements in the array are less than or equal to the threshold; false otherwise.

Exceptions

ArgumentNullException

source is null

ArgumentOutOfRangeException

threshold is negative.

Example

The following code example demonstrates how to use AtMost(int threshold) to determine whether the number of elements is at least equal to a given threshold.

int[] tooManyElements = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
tooManyElements.AtMost(8);
//=> false

int[] enoughElements = new int[]{1, 2, 3};
enoughElements.AtMost(5);
//=> true
⚠️ **GitHub.com Fallback** ⚠️