To make it possible or even easier for anybody to
create a good functional collection, you can use a class or derive one
from those that ship with the .NET Framework. Collections are highly used
by various other classes and Windows controls available in Microsoft
Visual Studio. To provide a common functionality to the collections, sets,
and series used in Windows applications and databases, the .NET Framework
provides various interfaces that you can implement. Doing this gives you
the double advantage of creating a collection class and getting familiar
with the common collections you will use in graphical applications.
Choosing a Class or an Interface
|
|
When you want to use
a collection in your application, you may first check what classes are
available in the .NET Framework. If you don't find a suitable class, you
can create your own that implements one or more interfaces. As it happens,
the .NET Framework ships with many of them and your next step is to choose
which one you prefer. Some of the most commonly used interfaces are
- IComparer: If you derive a class from this interface, you can
define how two objects would be compared for similarity or difference
- IDictionary: This interface is used to create a collection class
where each item is made of a key=value combination
|
|