Enumerable.Repeat method is part of the System.Linq namespace.
It returns a collection containing duplicate elements in C#.
First, set the elements to be repeated and the number of repetitions.
For example, let’s see how to repeat the number 10 five times−
Enumerable.Repeat(10, 5);
Here is the complete example−
Demonstration
using System; using System.Linq; class Demo { static void Main() { var val = Enumerable.Repeat(10, 5); foreach (int res in val) { Console.WriteLine(res); } } }
10 10 10 10 10
The above is the detailed content of Enumerable.Repeat method in C#. For more information, please follow other related articles on the PHP Chinese website!