Repeat
In this chapter you will learn:
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:
Home » C# Tutorial » Linq Operators