Repeat

In this chapter you will learn:

  1. How to use Repeat operator

Get to know Repeat

Repeat accepts the number to repeat, and the number of iterations. Repeat works only with integers.

using System;/*from  j  av a 2 s. c  o  m*/
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        foreach (int i in Enumerable.Repeat(5, 3))
        {
            Console.Write(i + " "); // 5 5 5
        }
    }
}

The output:

Next chapter...

What you will learn in the next chapter:

  1. How to use Reverse operator
  2. How to reverse a String array
Home » C# Tutorial » Linq Operators
Aggregate
Aggregate with seed
Aggregate string value
All
Any
Average
Cast
Concat
Contains
Count
DefaultIfEmpty
Distinct
ElementAt
ElementAtOrDefault
Empty
Except
FindAll
First
FirstOrDefault
GroupBy
Intersect
Last
LastOrDefault
LongCount
Max
Min
OfType
OrderBy
OrderByDescending
Range
Repeat
Reverse
SelectMany
SequenceEqual
Single
SingleOrDefault
Skip
SkipWhile
Sum
Take
TakeWhile
ThenBy
ThenByDescending
ToArray
ToList
Zip