How can .NET Collections be used for optimizing performance?
In the System.Collections namespace, you can find a series of classes and interfaces that define a series of objects that can be used to implement sets of closely related objects in your classes. This namespace includes collections that can be used immediately, such as ArrayList, Stack,Hashtable, and Queue, but it also includes interfaces such as IEnumerable that allow you to create your own collection classes. By having classes implement collections instead of dealing with groups of instances by means of arrays, all the caveats that using arrays usually bring, such as (but not limited to) run-time errors, invalid indexes, or array length tracking, are no longer concerns. By implementing collections, you are also following good object-oriented practice in the sense that you can easily employ other concepts such as inheritance and polymorphism in the future. Following this approach will also aid you in avoiding errors in the future by re-utilizing stable code.