Reflection and Generics

In .NET Framework 2.0, Reflection was extended to accommodate open and closed generic types and methods. The Type class is the focal point of changes that extend reflection to accommodate generic types, while MethodInfo has been enhanced to reflect generic methods. (Generics were introduced in Chapter 7.) Open constructed types are generic types with unbound type parameters, whereas closed constructed types have bound type arguments. With Reflection, you can browse bound and unbound parameters, create instances of generic types, and invoke generic methods at run time.

IsGeneric and IsGenericTypeDefinition

With reflection, you can query the status of a type or method. Is a type or method generic? If generic, is the type or ...

Get Programming Microsoft® Visual C#® 2008: The Language now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.