Let\'s say that I have the methodInfo for something like Nullable
.
Is there anyway to convert it to Nullable
Solved it. But the big question is this a safe way to do it? Is there something I could be doing wrong here?
public static MethodInfo Convert(this MethodInfo method,params Type[] DeclaringTypeArguments)
{
var baseType = method.DeclaringType.GetGenericTypeDefinition().MakeGenericType(DeclaringTypeArguments);
return MethodInfo.GetMethodFromHandle(method.MethodHandle, baseType.TypeHandle) as MethodInfo;
}
public static void Main(String[] args)
{
List list = new List();
Action action = list.Add;
Console.WriteLine(action.Method.Convert(typeof(string)));
Console.Read();
}