The Repeat operator generates a sequence by repeating a specified element a specified number of times.
public static IEnumerable<T> Repeat<T>( T element, int count);
Repeat is not an extension method. It is a static method called on System.Linq.Enumerable.
ArgumentOutOfRangeException is thrown if the count is less than zero.
The following code will generate a sequence containing ten elements where each element is the number 2.
using System; using System.Linq; using System.Collections; using System.Collections.Generic; class Program//from w w w . ja v a2s.c o m { static void Main(string[] args) { IEnumerable<int> ints = Enumerable.Repeat(2, 10); foreach(int i in ints) Console.WriteLine(i); } }