Is there a way to initialize all elements of an array to a constant value through generics?
Personally, I would use a good, old for loop, but if you want a one-liner, here it is:
T[] array = Enumerable.Repeat(yourConstValue, 100).ToArray();
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