This post originated from an RSS feed registered with .NET Buzz
by Eric Gunnerson.
Original Post: A few generics terms
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
I've been diving into generics a bit more deeply, and I'd like to share some of the
new terminology that will be floating around.
Open Type
An open type is a generic type that you've defined. List<T> is a good example.
It's called "open" because it's not fully defined without knowing what T is, and therefore
you can never have an instance of this type.
Type Parameter
The type placeholder that you use when writing a generic type. In List<T>,
T is the type parameter.
Constructed Type
A constructed type is what you get when you specify a type for a type parameter. List<int>
is a constructed type, and you can create instances of it.
Type Argument
The actual type you use instead of the type parameter when creating a construct type .
In List<int>, int is the type argument.
Generic Method
A method that has a type parameter on it.
static int Process<T>(T t);
is an example
Arity
Strictly speaking, the number of parameters to a method. In generic terms, it's the
number of type parameters on a generic type or method. ArrayList has an arity of zero,
while List<T> has an arity of one.