Using Generic Types
In our discussion about generic types, you learned how a generic type is used repeatedly. Let’s concentrate on the phonebook example a bit more:
In the preceding code, we’re making a constructed generic type by substituting the TKey
type parameter for string
and the TValue
type parameter for int
. As you expect from a great development environment, Visual Studio provides IntelliSense when supplying types for generic type parameters, as shown in Figure 15.9.
Figure 15.9. Creating a constructed generic type with help from Visual Studio.
Behind the scenes, the type parameterization specified while creating a constructed generic ...
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.