Generation Operators

Have you code like this?

var numbers = new List<int>();
for (var i = 0; i<10; i++){
    numbers.Add(i);
}

// numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

With LINQ, we can make it in one line of code.

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

But, it only works with integer only.

var repeatString = Enumerable.Repeat("Makers is awesome", 10);

results matching ""

    No results matching ""