How to create a sequence of integers in C#?

Budda picture Budda · Jan 3, 2011 · Viewed 56.7k times · Source

F# has sequences that allows to create sequences:

seq { 0 .. 10 }

Create sequence of numbers from 0 to 10.

Is there something similar in C#?

Answer

alexn picture alexn · Jan 3, 2011

You can use Enumerable.Range(0, 10);. Example:

var seq = Enumerable.Range(0, 10);

MSDN page here.