Click here to Skip to main content
12,955,170 members (64,275 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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[^]. :)

Regards
  Permalink  
v2
Comments
Prashant Srivastava LKO 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 [^]?
: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
Top Experts
Last 24hrsThis month
OriginalGriff 6,559
CHill60 3,550
Maciej Los 3,153
ppolymorphe 2,030
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 28 Feb 2012
Copyright © CodeProject, 1999-2017
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