字符串列表和ArrayList有什么区别. [英] What is the difference between List of string and ArrayList.
本文介绍了字符串列表和ArrayList有什么区别.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
List< string>有什么区别?和ArrayList.
解决方案
我想的不多-因为这里没有装箱/拆箱.
实施列表< t>可能仍会在性能上表现更好,因为不需要在运行时进行任何类型检查.
关于该主题的另外两个有趣的读物-
http://blogs.msdn.com/b/joshwil/archive/2004/04/13/112598.aspx [ ^ ]
http://blog.drorhelper.com/2008/10/why-should-i-use-list-and-not-arraylist.html [ Google想出了什么. [ ^ ]
通用List
效率更高,因为它仅处理指定的对象类型.ArrayList
需要装箱,因为它在单个列表中支持多种类型.最好总是使用List
而不是ArrayList
.
What is the difference between List<string> and ArrayList. Is there any performance issue?
解决方案
Not much I would think - since there is no boxing / unboxing here.
Implementing List<t> might just still come out better in terms of performance because there is no need to do any type checking at runtime.
Two more interesting reads on this topic -
http://blogs.msdn.com/b/joshwil/archive/2004/04/13/112598.aspx[^]
http://blog.drorhelper.com/2008/10/why-should-i-use-list-and-not-arraylist.html[^]
The difference is that you perform boxing/unboxing (casting thestring
toobject
and vice verca) withArrayList
, and genericList<string>
allows you to avoid it. Performance of generic classes is better.
And that''s what Google came up with.[^]
A genericList
is more efficient because it deals with just the specified object type. AnArrayList
requires boxing because it supports multiple types in a single list. It''s almost always better to use aList
rather than anArrayList
.
这篇关于字符串列表和ArrayList有什么区别.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文