ArrayList与List [英] ArrayList vs. List
问题描述
我注意到在我的代码中,它本质上是客户端的api,
我将ArrayList对象返回给客户端。在我的情况下,列表包含
一些用户只需要迭代的对象,因此没有
修改列表是在我填充之后完成的。
您认为这个要求的最佳数据结构是什么?
谢谢
I noticed in my code, which is essentially an api for the client, that
I return ArrayList object to the client. In my case, list consist of
some objects that user only need to iterate over, hence no
modification to list is done after it filled by me.
What do you think is the best data structure for this requirement?
Thanks
推荐答案
10月16日上午11:05,puzzlecracker< ironsel2 ... @ gmail.comwrote:
On Oct 16, 11:05 am, puzzlecracker <ironsel2...@gmail.comwrote:
我在我的代码中注意到,这是本质上是客户端的api,
我将ArrayList对象返回给客户端。在我的情况下,列表包含
一些用户只需要迭代的对象,因此没有
修改列表是在我填充之后完成的。
您认为此要求的最佳数据结构是什么?
谢谢
I noticed in my code, which is essentially an api for the client, that
I return ArrayList object to the client. In my case, list consist of
some objects that user only need to iterate over, hence no
modification to list is done after it filled by me.
What do you think is the best data structure for this requirement?
Thanks
您应该返回一个只读集合。看看
ReadOnlyCollection,它在System.Collections.ObjectModel
You should return a readonly collection. Take a look at
ReadOnlyCollection , it''s in System.Collections.ObjectModel
10月16日,11:27 * am, ; Ignacio Machin(.NET / C#MVP)"
< ignacio.mac ... @ gmail.comwrote:
On Oct 16, 11:27*am, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On 10月16日,上午11:05,puzzlecracker< ironsel2 ... @ gmail.comwrote:
On Oct 16, 11:05 am, puzzlecracker <ironsel2...@gmail.comwrote:
我在我的代码中注意到,这本质上是客户端的api那个
我将ArrayList对象返回给客户端。在我的情况下,列表包含
一些用户只需要迭代的对象,因此没有
修改列表是在我填充之后完成的。
I noticed in my code, which is essentially an api for the client, that
I return ArrayList object to the client. In my case, list consist of
some objects that user only need to iterate over, hence no
modification to list is done after it filled by me.
您认为此要求的最佳数据结构是什么?
What do you think is the best data structure for this requirement?
谢谢
Thanks
你应该返回一个只读集合。看看
ReadOnlyCollection,它在System.Collections.ObjectModel
You should return a readonly collection. Take a look at
ReadOnlyCollection , it''s in System.Collections.ObjectModel
我认为它是3.0+的一部分,我需要支持.NET 2.0 ...建议?
I think it is part of 3.0+, I need to support .NET 2.0... suggestions?
" puzzlecracker" < ir ********* @ gmail.comwrote in message
news:38 ********************* ************* @ k16g2000 hsf.googlegroups.com ...
"puzzlecracker" <ir*********@gmail.comwrote in message
news:38**********************************@k16g2000 hsf.googlegroups.com...
10月16日上午11:27, Ignacio Machin(.NET / C#MVP)"
< ignacio.mac ... @ gmail.comwrote:
On Oct 16, 11:27 am, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
> 10月16日上午11:05,puzzlecracker< ironsel2 ... @ gmail.comwrote:
>On Oct 16, 11:05 am, puzzlecracker <ironsel2...@gmail.comwrote:
我在我的代码中注意到,这实际上是一个api for the客户端,那个
我将ArrayList对象返回给客户端。在我的情况下,列表包含
一些用户只需要迭代的对象,因此没有
修改列表是在我填充之后完成的。
I noticed in my code, which is essentially an api for the client, that
I return ArrayList object to the client. In my case, list consist of
some objects that user only need to iterate over, hence no
modification to list is done after it filled by me.
您认为此要求的最佳数据结构是什么?
What do you think is the best data structure for this requirement?
谢谢
Thanks
你应该返回一个只读集合。看一下
ReadOnlyCollection,它在System.Collections.ObjectModel
You should return a readonly collection. Take a look at
ReadOnlyCollection , it''s in System.Collections.ObjectModel
我认为它是3.0+的一部分,我需要支持。 NET 2.0 ...建议?
I think it is part of 3.0+, I need to support .NET 2.0... suggestions?
为什么不在内部使用ArrayList然后将ArrayList转换为
数组并返回?
基普
Why not use an ArrayList internally and then convert the ArrayList to an
array and return that?
Kip
这篇关于ArrayList与List的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!