Hash List to Hash 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> /// ArrayListHashtableHashtable /// </summary> /// <param name="htList"></param> /// <param name="htArray"></param> public static void HashList2HashArray(System.Collections.Hashtable htList, System.Collections.Hashtable htArray) { System.Collections.IEnumerator it = htList.Keys.GetEnumerator(); while (it.MoveNext()) { Object obj = it.Current; System.Collections.ArrayList alList = (System.Collections.ArrayList)htList[obj]; if (alList.Count > 0) { 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]; } htArray[obj] = objArray; } else htArray[obj] = null; } } } }