If you need to use an ArrayList and cannot start using List, and you know the type of each element in this ArrayList, which you can do:
string[] stringArray = myArrayList.ToArray(typeof(string)) as string[];
If something in myArrayList was not a string, then you will get an InvalidCastException.
If you can, I would start using List, as mentioned by OregonGhost.
source share