ArrayList与List<> [英] ArrayList vs. List<>

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

问题描述

List的文档说List类是

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


Zytan

解决方案

Zytan< zy**********@gmail.com写道:


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



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

2.0,以及泛型。


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

中立。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http ://www.msmvps.com/jon.skeet

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


两者之间存在很大的性能差异,有利于

列表。大多数情况下,人们因为习惯而使用arraylist,而且功能上比名单更熟悉。最终,这应该会改变。


-

问候,

Alvin Bruney

- -------------------------------------------------- ---

无耻的作者插件

Excel的.NET服务即将推出...

OWC亚马逊上的黑皮书和
www.lulu.com/owc

专业版VSTO 2005 - Wrox / Wiley

" Zytan" < zy ********** @ gmail.comwrote in message

news:11 ******************** **@q75g2000hsh.googlegr oups.com ...


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


Zytan



5月7日,3日:52 pm,Zytan< zytanlith ... @ gmail.comwrote:


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


Zytan



.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

解决方案

Zytan <zy**********@gmail.comwrote:

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?

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


There is a whole lot of performance difference between the two in favor of
lists. Mostly, people use arraylist because of habit and it is functionally
more familiar than lists are. Eventually, that should change though.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Zytan" <zy**********@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...

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



On May 7, 3:52 pm, Zytan <zytanlith...@gmail.comwrote:

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

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;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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