Sams Teach Yourself Visual C#® 2010 in 24 Hours by Scott Dorman

Sams Teach Yourself Visual C#® 2010 in 24 Hours by Scott Dorman

Author:Scott Dorman
Language: eng
Format: mobi
Tags: Technical
Publisher: SAMS
Published: 2010-07-15T07:00:00+00:00


Combining Generics and Arrays

In Hour 9, you learned that all single-dimensional arrays that have a lower bound of zero automatically implement IList<T>. As a result, you can create a generic method that iterates over the contents of an IList<T> that will work for any of the collection types (because they all implement IList<T>) and any single-dimensional array.

Listing 11.12 shows an example of such a generic method.

Listing 11.12 Printing Collection Items with a Generic Method

Variance in Generic Interfaces



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.