Ankit Singh
What are the differences in Arraylist And GenericList.
By Ankit Singh in C# on Mar 13 2013
  • Manju lata Yadav
    Sep, 2014 14

    ArrayList:- 1. "System.Collections" is the Namespace for Arraylist. 2. We create a ArrayList like:- System.Collections.ArrayList list1 = new System.Collections.ArrayList(); list1.Add(3); It means do not need to specify which datatype is going to be stored. 3. It is not type-safe at compile-time. Its shows errors at runtime. 4. Any reference or value type that is added to an ArrayList is implicitly upcast to Object. If the items are value types, they must be boxed when added to the list, and unboxed when they are retrieved. Both the casting and the boxing and unboxing operations degrade performance GenericList:- 1. "System.Collections.Generic" is the Namespace for generic List. 2. We can initialize GenericList: List list1 = new List(); list1.Add(3);3. It is a collection that is type-safe at compile-time. 4. There is no boxing and unboxing. It is faster

    • 1
  • Ankit Singh
    Mar, 2013 13

    Arraylist accept values as object.so it will return that values as object.we have to cast that value from object to its original type.

    whereas
    Generic list is specify the type of data we are going to insert in to list.so that we can avoid boxing and unboxing.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS