ArrayList vs Generic collections

人走茶凉 提交于 2019-12-23 16:28:00

问题


what are pros and cons to use ArrayList instead generic collection in NET 2.0


回答1:


Generic collections are type-safe - you cannot put a string into a List<int> - and don't require constant boxing/unboxing from object.

ArrayList on the other hand can handle a mix of different elements - this can be a plus in certain cases.

My take: typically I always use List<T> - unless I really need something that can handle int, string, DateTime etc. at the same time (very rare occasions).



来源:https://stackoverflow.com/questions/2956026/arraylist-vs-generic-collections

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!