C#将hashtable的值转换到数组中的代码

下边内容内容是关于C#将hashtable的值转换到数组中的内容,应该对各位有些用。

var length = ht.Count;
Guest[] array = new Guest[length];
ht.Values.CopyTo(array, 0);

其中ht为hashtable,其key为字符串,value为一个Guest类,通过此代码可以讲values的值全部放入Guest[]的数组中

猜你喜欢

转载自blog.51cto.com/14135053/2341090