1. The list's ToArray () method is used to convert the collection to an array, but in fact the method is defined in the collection, so all the collections have this function,
There are two methods: Object "" ToArray () and t<t> [] ToArray (t[] a) The second method is more commonly used, and we can pass in an array of the specified type.
The element type of the data should be the same as the element type of the collection, and the return value is the transformed array, which holds all the elements in the collection.
eg
List<string> List = new ArrayList<String> ();
List. Add("a");
List. Add("B");
List. Add("C");
String[] strarr = List. ToArray(new String[] {});
System. Out. println(Arrays. ToString(Strarr)); //[A, B, c]
2, List converts an array to
List string[] Strarr = { "a" "B" "C" }
List<String> List = Arrays. Aslist(Strarr);
System. Out. println(list); //[A, B, c]
List arrays and collections convert to each other