Check ParameterType.IsGenericParameter
.
You may also want to check ContainsGenericParameters
, which will be true for something like MyMethod<T>(List<T> param)
. (Even though List<>
isn't a generic parameter)
If IsGenericParameter
is true, you can also call GetGenericParameterConstraints()
to get interface or base type constraints, and you can check GenericParameterAttributes
(a [Flags]
enum) for new()
, struct
, or class
constraints.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…