Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is IsGenericParameter false for a generic parameter out T

Tags:

I have a method defined like this:

public bool TryGetProperty<T>(string name, out T value)

Looking at the MethodInfo for this method, I find

methodInfo.GetParameters()[1].ParameterType.IsGenericParameter

is false. I expected it to be true, because the second parameter has a type of T. (On the other hand, methodInfo.GetParameters()[1].ParameterType.ContainsGenericParameters is true.)

Why is IsGenericParameter false in this case? And what is the correct way to verify that the second parameter has a type of T. For instance, I'm trying to find the correct method by filtering the results of Type.GetMethods().