Thursday, 17 September 2009

Defining closed vs open generic types

Generic types can be open or closed. A closed generic type is defined as follows:
"A constructed generic type that has no unspecified generic type parameters, either of its own of or any enclosing types or methods. Closed generic types can be instantiated. See also: constructed generic type, generics, generic type, generic type parameter, open generic type."
Conversely an open generic type is defined as follows:
"A constructed generic type in which one or more of the generic type arguments substituted for its generic type parameters is a type parameter of an enclosing generic type or method. Open generic types cannot be instantiated. See also: closed generic type, constructed generic type, generics, generic type argument, generic type parameter."
So, IList<Person> is a closed generic type, IList<T> is an open generic type.
Thursday, 17 September 2009,