Mid Collections

How would you convert a List<T> into an array in C#?

Use ToArray() method.

Example:

int[] array = list.ToArray();

Useful when interfacing with APIs that require arrays.

More from C# Programming Tutorial

All questions for this course