Functional programming with Linq — Enumerable.Range

In my Learn­ing F# posts you prob­a­bly saw how you can gen­er­ate an int array like this:

let x = [1 .. 10];;

this returns 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

This is pret­ty cool, and for­tu­nate­ly, you have some­thing very sim­i­lar­ly in C# with Enumerable.Range which you can use by sup­ply­ing a start­ing num­ber and a count:

var x = Enumerable.Range(1, 10);

Liked this post? Why not support me on Patreon and help me get rid of the ads!