Let\'s say that I have the methodInfo for something like Nullable
.
Is there anyway to convert it to Nullable
You can do it in one line with MethodBase.GetMethodFromHandle
but in order to use this method you'll have to pass typeof(List
not just typeof(string)
.
var methodinfo = typeof(List).GetMethod("Add");
var methodinfo2 = MethodBase.GetMethodFromHandle(methodinfo.MethodHandle,
typeof (List).TypeHandle);
Console.WriteLine(methodinfo);
Console.WriteLine(methodinfo2);
This link includes the above sample and an exlpanation of why ResolveMethod
doesn't work.
https://www.re-motion.org/blogs/mix/archive/2009/08/12/trying-to-resolve-a-method-in-a-closed-generic-type.aspx