ArrayList与通用集合 [英] ArrayList vs Generic collections
本文介绍了ArrayList与通用集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在NET 2.0中使用ArrayList代替常规集合的优缺点
what are pros and cons to use ArrayList instead generic collection in NET 2.0
推荐答案
常规集合是类型安全的-您不能将字符串
放入 List< int>
-并且不需要从<$ c进行连续装箱/拆箱$ c> object 。
Generic collections are type-safe - you cannot put a string
into a List<int>
- and don't require constant boxing/unboxing from object
.
ArrayList
可以处理
我的观点:通常我总是使用 List< T>
-除非我真的需要可以同时处理 int,字符串,DateTime
等(很少见)的东西。
My take: typically I always use List<T>
- unless I really need something that can handle int, string, DateTime
etc. at the same time (very rare occasions).
这篇关于ArrayList与通用集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文