Method AtLeast
| Edit this page View SourceAtLeast<T>(IEnumerable<T>, int)
Determines whether or not the number of elements in the sequence is greater than or equal to the given integer.
Declaration
public static bool AtLeast<T>(this IEnumerable<T> source, int count)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The source sequence |
int | count | The minimum number of items a sequence must have for this function to return true. |
Returns
Type | Description |
---|---|
bool | true if the number of elements in the sequence is greater than or equal to the given integer, false otherwise. |
Type Parameters
Name | Description |
---|---|
T | Element type of sequence |
Remarks
This method executes immediately.
Examples
The following code example demonstrates how to check that a sequence has a minimum size using AtLeast
.
var sequence = Enumerable.Range(1, 5);
foreach (var x in Enumerable.Range(3, 5))
{
// Check that a sequence has a minimum size
var result = sequence.AtLeast(x);
Console.WriteLine($"AtLeast {x}: {result}");
}
// This code produces the following output:
// AtLeast 3: True
// AtLeast 4: True
// AtLeast 5: True
// AtLeast 6: False
// AtLeast 7: False
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|