Hi,
I am priya and i would like to know the following details
What are the collection classes inC#?
What is the use and advantage of collection classes?
How to write programs using collection?
How we can use the collecion classes i C# program?
Plzzzzzzzz help me?
Priya
sandeep talabathulaPosted Jan 23, 2008, 6:34 AM
Joel CochranPosted Jan 22, 2008, 11:22 AM
The other problem Generics solve is constant casting: when you store objects in a Collection as an object type, it has to get upcasted to be added to the Collection. When you read the object back out, you must know what type it is, and you must downcast it back to the correct type. This is very expensive and requires a lot of extra work, both for you the developer and the runtime engine.
So by all means, spend a little time learning about Collection types, but do yourself a favor and quickly move on to Generic Collections.
Scott LyslePosted Jan 21, 2008, 7:51 AM
Priya:
You should investigate the contents of System.Collections to get a good understanding of its content. In general you collections are used to contain collections of objects; different types of collections work differently in terms of how data is stored in the collection and later retrieved from that collection.
System.Collections contains ArrayLists, HashTables, SortedLists, Stacks, and Queues.
Stacks and Queues are ordered and data is recovered from such queues in a specific order; stacks are last in-first out and queues are first in-first out. The order in which you store data in a stack or queue dictates the order in which it will be recovered.
ArrayLists are indexed collections (zero based) and work like arrays in terms of how you might recover the objects stored in them.
HashTables and SortedLists store data in key-value pairs and you can recover objects (values) by identifying the key.
Of course you should also looking into the topic of Generics when considering .NET collections.