The GenericArguments
property of the TypeDescription
class provides access to the generic parameters of a type if it is a generic type. This property returns an array of System.Type
objects, each representing a generic parameter of the type.
The GenericArguments
property of the TypeDescription
class provides access to the generic parameters of a type if it is a generic type. This property returns an array of System.Type
objects, each representing a generic parameter of the type.
Use the GenericArguments
property to retrieve the generic parameters of a type when working with generic types. This can be useful for reflection or when you need to inspect the type parameters of a generic type at runtime.
// Example of using the GenericArguments property TypeDescription typeDescription = TypeLibrary.GetTypeDescription(typeof(List<>)); if (typeDescription.IsGenericType) { System.Type[] genericArgs = typeDescription.GenericArguments; foreach (var arg in genericArgs) { // Output the name of each generic argument Console.WriteLine(arg.Name); } }