Declaring Generic Types

Let’s take a closer look at how generic types are declared. We’ve already seen the syntax used, using angle brackets < and > to specify a comma-separated list of type parameters. For example, here’s another generic collection type with two type parameters:

class Dictionary<TKey, TValue>

Visual Basic Syntax

When talking about generic types, use the word of to separate the name of the type from its type parameters, as denoted by angle brackets in C#. Visual Basic sounds like plain English language and uses the Of keyword to make this explicit:

Class List(Of T)    '...End Class

To construct a type out of the generic type, the same of keyword is used, followed by the type to be substituted for the type parameter in that ...

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.