Using Repeat to generate a sequence that contains the number 7 ten times. : Enumerable.Repeat « LINQ « C# / CSharp Tutorial






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








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