How to convert an ArrayList into an Array?

 Posted by Raja on 7/14/2008 | Category: ASP.NET Interview questions | Views: 7037

Lets say you have myPersonList as an ArrayList that has Person object. If you want to convert this ArrayList into array of your Person object, write like this.

Person[] personArray = (Person[])myPersonList.ToArray(typeof(Person));

Here you need to cast the object into its type.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response