DotNet Tutorials:Collections and Generics

The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries.

A collection is an object, which would manage other objects i.e. ArrayList, Hash Table, Stack, Sorted List etc..

Basically the ICollection has the IList and IDictionary. IList is a type of ArrayList which will have an index and a corresponding value. They do not support insertion and deletion but is used only for retrieving the data. IDictionary has the Hash table which are in the form of key - value pairs.

ArrayList implements IList interface as specified above using an array whose size is dynamically increased as required. The capacity of a array list is the number elements the ArrayList can hold. The default initial capacity for an array List is '0'.

The capacity of a hash table is the number elements the hashtable can hold. The default initial capacity for an hash table is '0'.

Generics class is not specific to any data type. But the instance of such a class would be specific to a given data type mentioned at the time of creating instance/object of that class.

Generics allow you to define type-safe data structures, without providing or using actual data types. This results in a significant performance of higher quality code, because you get the opportunity to process data algorithms without duplicating that type-specific code.
Get all the Collections and Generics interview questions at bestdotnettraining.

Comments

  1. Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.
    Vee Eee Technologies| Vee Eee Technologies|

    ReplyDelete

Post a Comment