2. What are Collections Collections are the group of similar and dissimilar objects.Thorugh collections we can implement different various structures. Collections implement various classes as well Collections provide a way to store arbitrary objects in a structured fashion, and we all know how useful they are in everyday programming.
3. Need of Collections 1.Gives Non Persistent Data Structure. 2.It provides specialized classes for data storage and retrieval. 3. The interfaces may be inherited to create new collection classes. 4. Well tested and efficient methods are provided so user does not have to spent time in constructing methods.
4.
5.
6.
7. Generic Collections It allow users to create collections that provide better type safety and performance than non-generic strongly typed collections .Applications that target version 2.0 and later of the .NET Framework should use the generic collection classes Example :- instead of using the Hashtable class, which allows keys and values to be of any type, you can use the Dictionary generic class and specify the type allowed for the key and the type allowed for the value.
8.
9. Generic vs. Non Generic Collections Non-Generic Similar Generic Type ArrayList List<T> Hashtable Dictionary<TKey,TValue> SortedList SortedList<TKey,TValue> Queue Queue<T> Stack Stack<T> N/A SortedDictionary<TKey,TValue> N/A KeyedCollection<TKey,TItem> N/A LinkedList<T>
10.
11. Conclusion Collections are a vital element of any object-oriented architecture. Offering the capability to group objects in logical constructs, they improve code readability and self documentation, as well as enhance maintainability. As we see that collections reduces the Programming effort and increases program speed and Quality so it is always a good practice to use collections.