Is there a short way of converting a strongly typed List
to an Array of the same type, e.g.: List
to MyClass[]
Try using
MyClass[] myArray = list.ToArray();
One possible solution to avoid, which uses multiple CPU cores and expected to go faster, yet it performs about 5X slower:
list.AsParallel().ToArray();
List<int> list = new List<int>();
int[] intList = list.ToArray();
is it your solution?
To go twice as fast by using multiple processor cores HPCsharp nuget package provides:
list.ToArrayPar();
Use ToArray()
on List<T>
.
list.ToArray()
Will do the tric. See here for details.