arraylist和hashtable [英] arraylist and hashtable

查看:123
本文介绍了arraylist和hashtable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



C#中哈希表与arraylist的区别是什么。

和他们的比例。

谢谢

解决方案

我在Google上搜索了这个,难怪我有很多有用的链接。



C#中哈希表和arraylist之间的差异。


表格中的问题{有什么区别? 0}和{1}原则上是不正确的,不应该这样回答。



我最好给你一些实用的建议:不要使用任何一个他们。这些类不使用泛型并强制您使用类型转换,这是一个bug的邀请。这些类被泛型类所取代,并在.NET Framework 2.0版中引入了泛型。现在你正在使用v.4.0。此外,没有必要注意与2.0之前的.NET Framework版本的兼容性。



而不是 ArrayList 使用 System.Collections.Generic.List ,而不是 HashTable 使用以下其中一项: System.Collections.Generic.Dictionary System.Collections.Generic.SortedDictionary System.Collections.Generic。排序列表。主要区别在于内存开销与不同数据集上不同操作的速度之间的权衡。阅读每个MSDN帮助,选择最适合您需求的类: http:// msdn.microsoft.com/en-us/library/system.collections.generic.aspx [ ^ ]。



-SA

Hi,
what is the difference between hashtable and arraylist in C#.
and they's proportion.
thanks

解决方案

I searched this on Google, And no wonder I got many usefull links.

difference between hashtable and arraylist in C#.


The questions in the form "What's the difference between {0} and {1}" are incorrect in principle and should not be answered as such.

I would better give you some practical advice: don't use either of them. These classes do not use generics and force you into using type cast, which is an invitation for bugs. The classes were superseded by generic classes with introduction of generics in .NET Framework version 2.0. Now you're using v.4.0. Also, there is no need to take care about compatibility with .NET Framework versions prior to 2.0.

Instead of ArrayList use System.Collections.Generic.List, instead of HashTable use one of the following: System.Collections.Generic.Dictionary, System.Collections.Generic.SortedDictionary or System.Collections.Generic.SortedList. The differ mostly in trade-off between memory overhead and speed of different operations on different sets of data. Read the MSDN help on each to select the class best suited for your needs: http://msdn.microsoft.com/en-us/library/system.collections.generic.aspx[^].

—SA


这篇关于arraylist和hashtable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆