- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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