How to get generic method on closed generic type, having open MethodInfo from open generic type?

Not sure exactly what you are looking for, maybe expand on your question... This definitely would need some checks added (like checking if declaring type is generic / if method is generic, etc) var method = typeof(IAmGeneric). GetMethod("SoAmI"); var types = new { typeof(int), typeof(string) }; var methodTypeParams = method. GetGenericArguments(); var fullType = method.DeclaringType.

MakeGenericType(types. Take(types. Length - methodTypeParams.

Length).ToArray()); var fullMethod = fullType. GetMethod(method.Name). MakeGenericMethod(types.

Skip(types. Length - methodTypeParams. Length).ToArray()).

Here is a case that is pretty complex to get right : public interface IAmGeneric { void SoAmI(T one, T1 two, T2 three); void SoAmI(T one, T2 two, T1 three); void SoAmI(T1 one, T two, T2 three); void SoAmI(T2 one, T1 two, T three); void SoAmI(T2 one, T1 two, T3 three); } For me the solution is to use GetMethods(...).Select() and compare method name, parameter count, types and type parameters count to find the right method (basically everything that is part of the signature of the method).

Yeap, that might work, and that's what I'm doing right now. However the performance is far from stellar, hence I'm asking if there's a better way – Krzysztof Koźmic Sep 25 '10 at 2:55.

Look into reflection emit to optimize reflection performance where you can't avoid reflection.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions