Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Convert ArrayList to string[] (See related posts)

While seemingly obvious how to do this in .NET, it took a few tries to get this.
Given an ArrayList of strings, I wanted to convert it to a string array. Here's how.

string[] srtArray = arrList.ToArray(Type.GetType("System.String")) as string[];

Comments on this post

JacobC posts on Dec 05, 2006 at 16:55
try

string[] strArray = arrList.ToArray(typeof(string)) as string[];

You need to create an account or log in to post comments to this site.


Click here to browse all 4852 code snippets

Related Posts