Is there builtin method that would do this or do I always have to manually create a new array and then fill it up with a foreach loop
list.ToArray()
List<int> list = ...
...
int[] array = list.ToArray();
You can also use the CopyTo method :
int[] array = new int[list.Count];
list.CopyTo(array);
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