本文介绍了ArrayList与List<>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

List的文档说List类是

ArrayList类的通用等价物。由于List<是强类型的,而且ArrayList有
没有类型(被称为弱类型?),我会假设List<远远超过
更好。那么,为什么人们经常使用ArrayList呢?我错过了吗?
somehing?它们之间的区别是什么?


Zytan

解决方案



ArrayList从一开始就可用 - List< Tonly到达.NET

2.0,以及泛型。


有很多旧样本,以及希望保留版本的样本 -

中立。


-

Jon Skeet - < sk *** @ pobox.com>
博客:

如果回复小组,请不要给我发邮件






.NET框架版本1.x不支持泛型,所以除了使用非类型安全的ArrayList之外,你没有选择
。泛型是

一般首选,因为他们安全地推广类型,也因为他们

消除了对值类型的box / unbox集合的需要......

The docs for List say "The List class is the generic equivalent of the
ArrayList class." Since List<is strongly typed, and ArrayList has
no type (is that called weakly typed?), I would assume List<is far
better. So, why do people use ArrayList so often? Am I missing
somehing? What''s the difference between them?

Zytan

解决方案

ArrayList was available from the start - List<Tonly arrived in .NET
2.0, along with generics.

There are a lot of old samples, and samples which want to stay version-
neutral.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too




Version 1.x of the .NET framework did not support generics so you had
no option other than to use the non-type safe ArrayList. Generics are
generally preferred as they promote type safetly and also because they
eliminate the need to box/unbox collections of value type...


这篇关于ArrayList与List&lt;&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 09:19