Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Enumerable.Repeat method in C#
Enumerable.Repeat method is part of System.Linq namespace.
It returns a collection with repeated elements in C#.
Firstly, set which element you want to repeat and how many times.
As an example, let us see how to repeat number 10, five times −
Enumerable.Repeat(10, 5);
The following is the complete example −
Example
using System;
using System.Linq;
class Demo {
static void Main() {
var val = Enumerable.Repeat(10, 5);
foreach (int res in val) {
Console.WriteLine(res);
}
}
}
Output
10 10 10 10 10
Advertisements
