Programming Microsoft® Composite UI Application Block and Smart Client Software Factory
by David S. Platt
B. Solution Architecture
Version 2.0 of the .NET Framework supports parameterizing classes by a mechanism called generics. This mechanism looks and feels very much like the template mechanism in C++ or Java. The designer of a class, such as System.Collections.Generic.List, specifies that the class can accept a type as a parameter by using a special syntax, as shown on the facing page. Note that IntelliSense has properly detected the type that the generic list holds (in this case, string) and displays it, thus being more specific and therefore more useful.
The client programmer is passing the String type, saying, "Here, create me a list that holds only strings, please." Any attempt to store an object other than a string in that list causes a compiler ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access