Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArrayList vs Generic collections

Tags:

c#-2.0

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

like image 823
Arseny Avatar asked Feb 25 '26 15:02

Arseny


1 Answers

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

like image 142
marc_s Avatar answered Feb 28 '26 14:02

marc_s