Sometimes simple arrays are preferable to general lists, because they are more convenient (for example, higher performance for expensive computations -Numerical algebraic applications or for data exchange with statistics software such as R or Matlab)
In this case, you can use the ToArray () method after the list is run dynamically.
List<string> list = new List<string>(); list.Add("one"); list.Add("two"); list.Add("three"); string[] array = list.ToArray();
Of course, this only makes sense if the size of the array is never known or fixed in advance. if you already know the size of your array at some point in the program, it is better to initiate it as an array of a fixed length. (If you, for example, retrieve data from a ResultSet, you can calculate their size and dynamically initiate an array of this size)
Mehdi LAMRANI Nov 02 2018-10-11T00: 00Z
source share