Creating a Collection

The predefined collections are nice for a variety of tasks, but ultimately many programmers will want to have their own data structures. For maximum benefit and integration with the language, design your C# data structures as collections.

A List Collection

The SiteList class used in earlier chapters had many collection-like features. It was a wannabe collection, and its perseverance throughout the book was so admirable that I decided to design it as a full-fledged collection. Listing 26.7 shows the new full-featured SiteList collection in action.

Listing 26.7. The SiteList Collection Class: WebSites.cs
 namespace WebSites { using System; using System.Collections; /// <summary> /// Describes a single web site. /// </summary> ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.