Exactly - Kalkwst/Risotto GitHub Wiki
Determines whether or not the number of elements in the sequence is equal to the given limit.
In this page
Overload | Description |
---|---|
Exactly(int limit) | Determines whether or not the number of elements in the sequence is equal to the given limit. |
Determines whether or not the number of elements in the sequence is equal to the given limit.
public static bool Exactly<T>(this IEnumerable<T> source, int limit);
T
The type of elements in source
source
IEnumerable<T>
The sequence to count the elements of.
limit
Int32
The number of elements that should exist in source
.
Boolean
true
if the number of elements is equal to limit
, false
otherwise.
ArgumentNullException
source
is null
ArgumentOutOfRangeException
limit
is less than zero
The following code example demonstrates how to use Exactly(int limit) to validate the number of elements in a sequence.
Array.Empty<int>().Exactly(0);
//=> true
Array.Empty<int>().Exactly(1);
//=> false
new int[] { 1 }.Exactly(0);
//=> false
new int[] { 1 }.Exactly(1);
//=> true