开发者

ArrayList vs Generic collections

开发者 https://www.devze.com 2023-01-01 16:52 出处:网络
what are pros a开发者_C百科nd cons to use ArrayList instead generic collection in NET 2.0Generic collections are type-safe - you cannot put a string into a List<int> - and don\'t require constan

what are pros a开发者_C百科nd cons to use ArrayList instead generic collection in NET 2.0


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消