JS to C#: Array, ArrayList.... static array

So… in JS, I see Array and string[ ] or int[ ] easily passed back and forth from each other.

I believe Array can just be set = to a string[ ] and you must use string[ ] = Array.ToBuiltin().

Can someone share the proper ArrayList to static array back and forth code? (ToArray?)

Also…
Can someone give a performance primer on ArrayList (how bad is this to use?.. is there something better?)

On performance: for 99.99999% of anything you’ll need, any of those List structures are fine. Just need to be aware of how big your lists are (for instance are they holding a dozen or thousands of items) before it really matters.

Personally, I just use the List (may be ArrayList in C#) structure for everything that holds a list as Array is of a static size and offer less flexibility. The only downside is casting of types.

As for conversions:
List->Array: Lists should have a .ToArray() function, I believe.
Array->List: Lists can take an array as a variable to their constructor.

You can use ArrayList.CopyTo to transfer the contents of an ArrayList into a compatible array.

I am trying to use the ArrayList.CopyTo() method and I keep getting this error.

BCE0023: No appropriate version of 'System.Collections.ArrayList.CopyTo' for the argument list '(Array)' was found.

anyone have any insight?

You would use ArrayList.CopyTo() like so, to copy the elements of ‘a’ into ‘b’.

ArrayList a = new ArrayList();
int[] b = new int[a.Count];
a.CopyTo(b);

awesome thanks.