Click here to Skip to main content
15,041,025 members
Please Sign up or sign in to vote.
3.80/5 (3 votes)
See more:
What is the basic difference between Collection and Generics?

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[^]. :)

Prashant Srivastava LKO 19-Dec-11 12:59pm
Nice answer
Maybe it is similar to the difference between, say, searching the info with Google [^] or Bing [^]?
<b><u>Here is the exmaple of the Generic collections

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)

public myType this[int index]
return (myType)m_list[index];
m_list[index] = value;

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900