RSS 2.0 Feed
RSS 2.0


Atom 1.0 Feed
Atom 1.0

  More on Generics 


Here’s a great post from Eric Gunnerson’s blog on some new terminology we’ll see with generics.

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.

[Eric Gunnerson's C# Compendium]




                   



Leave a comment below.

Comments

  1. 9/19/2009 2:16 AM
    Gravatar
    jwmcypan - Google Search
  2. 11/22/2009 6:09 AM
    Gravatar
    fbqcvgle - Google Search
Comments have been closed on this topic.



 

News


Also see my CRM Developer blog

Connect:              


Sponsor

Sections