Possible Duplicate:
When to use ArrayList over array[] in c#?
从内存或处理器成本的角度来看,一个阵列和一个阵列对象之间似乎有显著差别吗?
Possible Duplicate:
When to use ArrayList over array[] in c#?
从内存或处理器成本的角度来看,一个阵列和一个阵列对象之间似乎有显著差别吗?
数组是一个低层次的数据结构,基本上映射到内存的区域。 ArrayList
是一个变量长度列表,它作为“code>object ”的数组执行,随着列表的增长被重新配置。
因此,ArrayList
有一些间接费用与内部阵列的大小管理有关,更多的间接费用与进入清单时将物体投入正确类型的有关。
此外,将所有内容作为 object
存储,意味着价值类型被框在书写上,而没有框在阅读上,这对性能极为有害。使用 List<T>
,一个类似但非常强烈的变量大小列表可以避免这一问题。
事实上,ArrayList
实际上被贬低为 List<T>
,自.NET 2. 0以来。
数组是固定大小的内存的毗连区块,而矩阵列表员(尽管您更喜欢列表,因为.NET 2. 0) 则将数组包起来,以提供动态可变存储。
两者之间的“差异”在于,只要它们重新封装,一个阵列是可变的,一个阵列不是。就执行而言:因为一个阵列包(和重新分配)阵列需要比一个阵列多一点的内存(因为它必须知道目前的元素数量,而不是其容量),此外,一个阵列还要求CPU在达到内部能力时有时间重新分配和复制其内部阵列。
然而,即时处理一个阵列并不比分配阵列更昂贵。 唯一的区别在于启动阵列状态需要为数不多的指示。 区别微乎其微,不值得担心。
你会发现,如果你自己重新定位一个阵列作为创建可变缩放收藏的手段,那么你最好使用矩阵列表/列表,因为它已经经过彻底测试。
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...