Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
What is the basic difference between Collection and Generics?
Posted 25-Feb-10 20:18pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Briefly, the basic difference between generic and non-generic collections:
 
- Non-Generic collections - These are the collections that can hold elements of different data types. It holds all elements as object type.
So it includes overhead of type conversions.
 
- Generic collections - These are the collections that can hold data of same type and we can decide what type of data that collections can hold.
 
Some advantages of generic collections - Type Safe, Secure, reduced overhead of type conversions.
 
You can read more about generics here[^]. Smile | :)
 
Regards
  Permalink  
v2
Comments
Prashant Srivastava LKO at 19-Dec-11 12:59pm
   
Nice answer
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Maybe it is similar to the difference between, say, searching the info with Google [^] or Bing [^]?
Roll eyes | :rolleyes:
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

<b><u>Here is the exmaple of the Generic collections
</u></b>
 

public class MyCustomList<MYTYPE>
{
   private ArrayList m_list = new ArrayList();
   public int Add(myType value)
   {
      return m_list.Add(value);
   }
 
   public void Remove(myType value)
   {
      m_list.Remove(value);
   }
 
   public myType this[int index]
   {
      get
      {
         return (myType)m_list[index];
      }
      set
      {
         m_list[index] = value;
      }
   }
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 530
1 Sergey Alexandrovich Kryukov 330
2 BillWoodruff 299
3 PIEBALDconsult 230
4 CPallini 220
0 Sergey Alexandrovich Kryukov 10,615
1 Maciej Los 5,354
2 OriginalGriff 5,254
3 CPallini 3,719
4 BillWoodruff 3,476


Advertise | Privacy | Mobile
Web04 | 2.8.141029.1 | Last Updated 28 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100