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 when you need to inspect the generic parameters of a type described by a TypeDescription
instance. This is particularly useful when working with generic types and you need to understand or manipulate their type parameters.
// Example of accessing GenericArguments 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); } }