JustAnswer.com

Thursday, February 22, 2007

Asp.Net Tutorials

these collections can literally store anything! For example, you could use a single
collection to
store a couple of integers, an instance of a classic COM component, a string, a date/time,
and two instances of a custom-written .NET component. Most of the examples in this section use collections to house primitive data types (strings, integers, doubles). However, Listing
2.1 illustrates a collection of collections—that is, a collection type that stores entire collections as
each of its elements! Throughout this section we’ll examine five collections the .NET Framework offers
developers: the ArrayList, the Hashtable, the SortedList, the Queue, and the Stack. As you study each of these collections, realize that they all have many similarities. For example, each type
of collection can be iterated through element-by-element using a For Each ... Next loop in VB (or a foreach loop in C#). Each collection type has a number of similarly named functions
that perform the same tasks. For example, each collection type has a Clear method that removes
all elements from the collection, and a Count property that returns the number of elements in
the collection. In fact, the last subsection “Similarities Among the Collection Types”
examines the common traits found among the collection types. Working with the ArrayList Class The first type of collection we’ll look at is the ArrayList. With an ArrayList, each item
is stored in sequential order and is indexed numerically. In our following examples, keep in
mind that the developer need not worry himself with memory allocation. With the standard array,
the

No comments: