C#idiomatic C#
generics-and-reflectioncsharp/advanced-topics/reflection-and-attributes

Advanced

Generics and reflection

Learn to use reflection to obtain information about generic types. View lists of terms and conditions for generic reflection.

  • page csharp/advanced-topics/reflection-and-attributes/generics-and-reflection
  • updated 03/05/2023

Because the Common Language Runtime (CLR) has access to generic type information at run time, you can use reflection to obtain information about generic types in the same way as for nongeneric types. For more information, see Generics in the Runtime.

The System.Reflection.Emit namespace also contains new members that support generics. See How to: Define a Generic Type with Reflection Emit.

For a list of the invariant conditions for terms used in generic reflection, see the System.Type.IsGenericType property remarks:

In addition, members of the System.Reflection.MethodInfo class enable run-time information for generic methods. See the System.Reflection.MethodBase.IsGenericMethod property remarks for a list of invariant conditions for terms used to reflect on generic methods:

See also