Collecting Data Items
Computers are usually good at dealing with large amounts of data. In our daily work as developer, we will find it necessary to store data in an orderly way. The .NET framework supports dealing with data in the way by providing a wide range of collections to store our data in. For every collection job, the .NET Framework supplies a solution.
Types of Collections
The .NET Framework's System.Collections namespace supports several types of collections. These collections are classes that support the gathering of information in an orderly way. Various types of collections are:
Name Description
- ArrayList A simple resizable, index-based collection of bytes
- SortedList A sorted collection of name/value pairs of objects.
- Queue A first-in, first-out collection of objects.
- Stack A last-in, first-out collection of objects.
- BitArray A compact collection of Boolean values.
- StringCollection A simple resizeable collection of strings.
- LastDictionary An efficient collection to store small lists of objects.
Adding and Removing Items

In C#
coll.Add("hi");
In contrast, the RemoveAt method removes an item at a particular index within the collection. For example:
In C#
coll.RemoveAt(0);
Iterating Over Items

In C#
for(int x=0; x<coll.count; ++x)
{
Console.WriteLine(coll[x]);
}
No comments:
Post a Comment