Csharp/C Sharp/LINQ/Enumerable.Repeat
Returning a Sequence of Ten Integers All With the Value Two
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
public static void Main() {
IEnumerable<int> ints = Enumerable.Repeat(2, 10);
foreach (int i in ints)
Console.WriteLine(i);
}
}
uses Repeat to generate a sequence that contains the number 7 ten times.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public static void Main() {
var numbers = Enumerable.Repeat(7, 10);
foreach (var n in numbers) {
Console.WriteLine(n);
}
}
}