Skip to content

Collections Classes

jaguRita

Asked Aug 10, 2007, 7:06 AM EDT2 answers
Share
LinkedInX

Hello,

I want to know read all interfaces and properties,methods in Collection Classes(ArryList,HashTable,List,n Etc..).I have searched in MSDN library.Do i get more information from any other site?

Thanks 2 all.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    Ok,Difference between Generic and Non-generic classes?

    And from what are all the interfaces inheriting methods n properties for Generic collection classes ?

    Please,Ur answer is valuable to me.

    Thanks.

    0
  • Mike Gold
    0

    Generic collections allow you to store an item in your collection of a specific type.

    non-generic collections allow you to store objects of any type all inheriting form the System.Object class.

    The biggest difference between the two types of collections, is that if you only need to store objects of a particular type (value or reference), then generic classes are much more efficient.

    The reason generic classes are more efficient is that you don't have to unbox the object inside the collection to get to the class instance you have stored there.

    Also it's easier to use a generic class as a programmer if all your objects are homogeneous because there is no coersion necessary for your type.

    for example:

    generic:

    List<int> listOfNumbers = new List<int>();  // generic instance

    C#
    list.Add(1);  list.Add(2);
    if I want to pull an element out of the list, I just need to get it directly:
    int  number = list[0];
    // non - generic example
    ArrayList list = new ArrayList();
    list.Add(1);
    list.Add(2);
    In a non-generic collection, To assign the first stored element  to a number, I need to unbox it  from the object type.
    int number = (int)list[0];
    0