The array class can be defined as follows:
VaR avalues = new array ();
If you know the length of the array in advance, you can use the parameter to pass the length
VaR avalues = new array (20 );
------------------ The following two definitions are the same -------- 1 -----------
VaR acolors = new array ();
Acolors [0] = "red ";
Acolors [1] = "green ";
Acolors [2] = "blue ";
Alert (acolors [0]); // output "red"
------------------------------------------------- 2 -----------
VaR acolors = new array ("red", "green", "blue"); // It is equivalent to array-defined arrays.
Alert (acolors [0]); // output "red" too
--------------------------
(1) convert array to string
The output of the above two array definitions is the same, and a comma separator is found in the middle.
Alert (acolors. tostring (); // output "red, green, blue ";
(2) convert string to array
We found that the array is converted to a string, with one separator ',' added between the arrays. Therefore, the string to be converted to an array must have a separator. It can be a comma or another separator.
VaR scolors = "red, green, blue ";
VaR acolors = scolors. Split (','); // the string is converted to an array.