If I am not wrong Generic collection stores the objects of specific types.
For example, List<String> stores objects of only String types.
Also String[] arr = new String[size] stores the objects of String types.
Both also support IEnumerable interface.
So I want to know the differences between Generic Collection and Arrays of Specific types.
1 Answer
An array is fixed size. You define the size up front and that's it. A collection like List<T> is of variable size. It supports adding and removing items from the collection. Behind the scenes a List<T> uses an array to store the items. It's smart enough to re-size the array whenever necessary.
So you shouldn't think about generic vs array but collection vs array. There are also non-generic arrays but there are few scenarios where you would use those.
You can find the documentation for List<T> here.
insert,add,delete,sort, then useList<>. If your priority is tofindby key, then both are bad (useHashtableto example). Arrays are good to hold fixed size data (to example, to organize cyclic buffer) or for size (memory) optimizing.