Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to fill List<> with elements

Tags:

c#

I have in my code

List<BookedReelsState> retVal = new List<BookedReelsState>(somesize);

Match later in the code if some condition works I need to fill this entire List with same value.

Of course I can do it via foreach loop and set values , Is there more elegant way to do so ? I just to learn something new here .

like image 977
Night Walker Avatar asked Dec 16 '10 08:12

Night Walker


1 Answers

retVal.AddRange(Enumerable.Repeat(value, somesize));
like image 79
Olaf Avatar answered Nov 15 '22 16:11

Olaf