Method Range
| Edit this page View SourceRange(int, int, int)
Generates a sequence of integral numbers within a specified range.
Declaration
public static IEnumerable<int> Range(int start, int count, int step)
Parameters
Type | Name | Description |
---|---|---|
int | start | The value of the first integer in the sequence. |
int | count | The number of sequential integers to generate. |
int | step | The step increment for each returned value. |
Returns
Type | Description |
---|---|
IEnumerable<int> | An IEnumerable<T>that contains a range of sequential integral numbers. |
Remarks
This operator uses deferred execution and streams its results.
Examples
The following code example demonstrates how to generate a sequence of values using Range
.
// Generate a sequence using a sequence function
var result = SuperEnumerable
.Range(1, 10, 2);
Console.WriteLine(
"[" +
string.Join(", ", result) +
"]");
// This code produces the following output:
// [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|