Is there any way to construct a list of type List<string> which contains a single string N times without using a loop? Something similar to String(char c, int count) but instead for List of strings.
List<string> list = new List<string>() { "str", "str", "str", ..... N times };
You can use Repeat():
List<String> l = Enumerable.Repeat<String>("foo", 100).ToList<String>();
It will still use a loop of course, but now you don't "see" it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With