This post will discuss how to convert List of Int to Array of Int in C#.

1. Using List<T>.ToArray() Method

The standard solution to convert a List<T> into a T[] is to invoke the List<T>.ToArray() method on the List. It copies all elements of a List<T> to a new array of the same type. The following example demonstrates the usage of the ToArray() method to create an array containing copies of the elements of the List.

Download  Run Code

2. Using List<T>.CopyTo() Method

The List<T>.CopyTo() method copies the List<T> (or a portion of it) to an array. You can use it as follows to convert a List of integers to an array of integers.

Download  Run Code

That’s all about converting List of Int to Array of Int in C#.