Home
C# Array To List, List To Array
Arrays are simple to create and use, Lists are easier to manipulate without getting bogged down in complex code.
Convert an Array to a List
List<string> MyList = new List<string>(MyArray);
The <string> bit tells C# what sort of list this is to be - much like string[]. So for integers you'd use
int32 MyArray = {1, 2, 3, 4}
List<int32> MyList = new List<int32>(MyArray);
Convert a List to an Array
string[] MyArray = MyList.ToArray();
So your list in the above would have to be a string array.
Reader's Comments
Name
Comment
Add a RELEVANT link (not required)
Upload an image (not required)
Uploading...
Home