Returning a Sequence of Ten Integers All With the Value Two : Enumerable.Repeat « LINQ « C# / CSharp Tutorial






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);

    }
}








22.36.Enumerable.Repeat
22.36.1.Using Repeat to generate a sequence that contains the number 7 ten times.
22.36.2.Returning a Sequence of Ten Integers All With the Value Two