Click here to Skip to main content
15,035,866 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello there

What the differences between Generic,Collection,Hashtable And guide me whn to use them.I also wnt to know is there any other concept similar to these in C#.

Ramesh ch Tulal
What is the difference between Brown, Horse, Saddle and Training?
This question is exactly as correct as the above one. Do I need to explain why?

A HashTable is a type of Collection of Generic types. You're looking for differences between unlike items.

A HashTable is used when you want a collection of unique values of an intrinsic type, such as integers or strings. You can use complex objects, but that means you have to somehow extends the HashTable class to support the type, or you must have a ToString() override in your collection object class. Given the hassles, and the performance issues regarding hashtables, you'd be better of with a simpl List if you want to use complex objects. Of course, you would still be on the hook for writing the AddUnique code, but that's pretty easy to do.
RameshChTulal 6-Jul-11 16:42pm
Mr.Simmons Please explain the 1st line in brief please...
RameshChTulal 6-Jul-11 16:47pm
And how Arraylist is differ or same...
1) Collection -
A group of integers, strings and objects,etc together...
You can add different data types to this, u can call it non-generic collection
you need to go through overhead of type conversion.

2) Generic - Collection of certain data types.
We need to define the datatype this Collection would hold.
It would be type safe and avoid run time type conversion problems with non-
generic counter part.

3) HashTable - Collection of certain types with KEY and VALUE of defined types.
Each Key of defined type would map a defined 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