How do I call SomeObject.SomeGenericInstanceMethod<T>(T arg)
?
There are a few posts about calling generic methods, but not quite like this one. The problem is that the method argument parameter is constrained to the generic parameter.
I know that if the signature were instead
SomeObject.SomeGenericInstanceMethod<T>(string arg)
then I could get the MethodInfo with
typeof (SomeObject).GetMethod("SomeGenericInstanceMethod", new Type[]{typeof (string)}).MakeGenericMethod(typeof(GenericParameter))
So, How do I go about getting the MethodInfo when the regular arguments are of a generic type? Thanks!
Also, there may or may not be type constrains on the generic parameter.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…