Summary

An overview of all nongeneric collection types is shown in Figure 16.5. Also notice the implementation of interfaces like ICollection and IEnumerable.

Figure 16.5. Nongeneric collection types (members filtered).

image

image Note that that the combination of IEnumerable and ICollection is enough to enable the use of the C# 3.0 collection initializer language feature:

var lst = new ArrayList { 1, 2, 3 };

The preceding code is equivalent to the following:

ArrayList __t = new ArrayList();__t.Add(1);__t.Add(2);__t.Add(3);ArrayList lst = __t;

This illustrates ...

Get C# 4.0 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.