Javatpoint Logo
Javatpoint Logo

LINQ Repeat Method

In LINQ, the Repeat method or operator is used to generate the collection with the same number as the repeated times based on the specified index value.

Syntax of LINQ Repeat Method

Here is the syntax of the LINQ Repeat method to generate the repeated number based on specified index values.

In the above syntax, we defined the Repeat method with two parameters. Here the first parameter tells the starting elements of the integer, and the second parameter is the one tells how many times the same number repeated in sequence.

Example of LINQ Repeat Method

Here is the example of the LINQ Repeat method to generate the collection, which contains the same number all the time.

In the above code, we defined the Repeated method in the Range(100,10). So it will take the starting number as "100" and it will generate the same number "10" times. This is because the second parameter is defined as 10; that is why it will return the same number10 times.

OUTPUT:

LINQ Repeat() Method

Here we show how we can use the LINQ Repeat method to generate the collection with the repeated number based on the specified length in C#.


Next TopicLINQ Empty Method




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA