Sunday, November 21, 2004

Converting ArrayList to the Class Array

Hi,

Sometimes we have data in the ArrayList and we need to convert it to our class type array.
ArrayList provides a method of ToArray that converts an ArrayList to the type of our class array.

here is what we can do:

return (Person[]) aList.ToArray(typeof(Person));

Here aList is the ArrayList.


No comments: