CKTIS / C#
Enumerable.Range: practical reference
Enumerable.Range: practical reference: Creates a deferred sequence of count consecutive Int32 values beginning at start.
Version: .NET LINQ; verified on .NET 10.0.14
Syntax
source.Range(/* overload-specific arguments */)Creates a deferred sequence of count consecutive Int32 values beginning at start.
Use it for indexes, demonstration data, and controlled functional loops without a manual array.
It does not allocate an array, but fully materializing a large range does. Values always increase by one.
A negative count or a range beyond Int32.MaxValue throws ArgumentOutOfRangeException; count 0 gives an empty sequence.
The complete program actually uses Enumerable.Range; its exact expected stdout is 3,4,5,6.
Examples
using System;
using System.Collections.Generic;
using System.Linq;
Console.WriteLine(string.Join(",", Enumerable.Range(3, 4)));
Result
3,4,5,6
The complete program actually uses `Enumerable.Range`; its exact expected stdout is `3,4,5,6`.