This chapter has discussed how to work with objects. We've seen how to create them, manipulate them, clone them, group them in collections, and destroy them. The chapter began with a description of how to use a factory design pattern to create objects. It closed with a look at how object resources are released through automatic Garbage Collection and how this process can be enhanced programmatically through the use of the Dispose and Finalize methods. In between, the chapter examined how to make applications more robust with the use of intelligent exception handling, how to customize the System.Object methods such as Equals and ToString to work with your own objects, how cloning can be used to make deep or shallow copies, and how to use the built-in classes available in the System.Collections and System.Collections.Generic namespaces.
As a by-product of this chapter, you should now have a much greater appreciation of the important role that interfaces play in application design. They represent the base product when constructing a class factory, and they allow you to clone (ICloneable), sort (IComparer), or enumerate (IEnumerable) custom classes. Knowing that an object implements a particular interface gives you an immediate insight into the capabilities of the object.