It is obvious that when we are designing business object or
Entities for our application we will create its corresponding collections. In
1.x days we used ArrayList for creating a collection of object or entity. We
can also create our own custom collection by inheriting the Arraylist or
CollectionBase in those times. The main disadvantage of using ArrayList is that
it can hold any type, which can cause some serious issue where a collection of
similar objects are expected. This is the right place in 1.x to go for our own
collection by inheriting the Arraylist or CollectionBase.
With the introduction of 2.0 Framework we got so many new
useful features that make our development easy in our applications. Generic
list is one of such feature which we can use for creating a collection of
similar objects. We can create our collection with generic List<T>, where
T can be our BO, which can be strongly typed. For example, List<Employee>
will allow only Employee instance to be added to the list. Moving forward we
will see how to implement sort to using generic list Sort overload methods and
also we will implement a custom enumerator that iterates through the list with
the use of yield keyword.