Difference between generic collections and non-generic collections


Generic collections can hold same type of data and we can decide while initializing what type of data that collections can hold.Non generic collections hold elements of different data types.
Generic collections reduced overhead of implicit and explicit conversions(because while initailing , will decide what type of data that collections can hold ). Non-generic collections include implicit and explicit conversions that means every data type will convert to and from object.So Generic collections give the best performance than non-generic collections.
    Generic collections are Type Safe and secure.
   
    examples of Generic collections are List , Dictionary etc.
    List<double> list = new List<double>();
   
    examples of non-Generic collections are ArrayList and Hash tables
    ArrayList arr = new ArrayList();

No comments:

Post a Comment