.ToArray() changes the dimension of my array

Viewed 166

In my C# program I've created an array of string:

var arrayTest = new string[20];

I need to copy in it some string that I retrive from a List containing 10 strings.

arrayTest = listTest.ToArray();

This works but .ToArray() changes the dimension of my array based on the number of element in the list.

I need to maintain the same size (20) and have the 10 strings and the 10 null (or whatever value..)

Is there a way to accomplish this other than loop listTest ?

3 Answers
Related