Convert a ArrayList object to a array
//http://tinyerp.codeplex.com/ //GNU Library General Public License (LGPL) //----------------------------------------------------------------------- // <copyright file="SysUtil.cs" company="Pyramid Consulting"> // Copyright (c) Pyramid Consulting. All rights reserved. // </copyright> //----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; namespace Bamboo.Core.Common { public class SysUtil { /// <summary> /// Convert a ArrayList object to a array /// </summary> /// <param name="alList">dest ArrayList to convert</param> /// <returns>dest array</returns> public static Object[] List2Array(System.Collections.ArrayList alList) { if (alList.Count == 0) return null; Object[] objSize = new Object[1]; objSize[0] = alList.Count; Type[] types = new Type[1]; types[0] = typeof(int); Object[] objArray = (Object[])alList[0].GetType().MakeArrayType().GetConstructor(types).Invoke(objSize); for (int i = 0; i < alList.Count; i++) { objArray[i] = alList[i]; } return objArray; } } }