|
|
||||||
|
#1
|
|
|
|
|
Hi there,
I wonder how to get a MethodInfo using System.Reflection.Type::GetMethod when the method has a parameter which is a generic method parameter. Consider this method: void MyMethod<T>( T myParam) { ... } I would like to use the GetMethod method to return the MethodInfo corresponding to MyMethod. The signature of GetMethod is: public sealed MethodInfo GetMethod( string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers ); The problem is: how to construct the 'types' argument since the 'myParams' parameter is of a generic method parameter (!!0). If I had the MethodInfo, I would make methodInfo.GetGenericArguments() to get the Type of 'myParam', but obviously I cannot use this technique since I do not have the MethodInfo at the moment where I want to get the type of the argument. There is a kind of hen-or-egg problem. There are of course workarounds, for instance using GetMethods() and iterating. But has anyone an idea how to solve this "cleanly"? Any suggestion would be helpful. Thank you. Gael Fraiteur |
|
|
|
#2
|
|
|
|
|
Any taker?
|
|
|
| Similar Threads | |
| How to retrieve a generic method with GetMethod (reflection) ? How to retrieve a generic method with GetMethod Code ------------------- #public static void Sort<T>( T[] array, Comparison<T> comparison [System.Reflection.MethodInfo]... |
|
| Generics Question - how to implement a method on a generic thatreturns the same type as the generic I am having a really bad time with this one. For some reason, I can't seem to remember how to implement this (elegantly) in c# ... so I thought I would ask the... |
|
| Type.GetMethod with Generic method I'm trying to get a method using Type.GetMethod. There are two methods with that same name, one is a standard method, the other is a Generic method. How do I get the Generic... |
|
| Type.GetMethod and ref Parameters in C# Hi All, I have a class (called CTestClass) within which I have a method (Foo). This method has the following signature: Foo(int x, int y, ref int z) I am attempting to use... |
|
| Type.GetMethod and ref Parameters in C# Hi All, I have a class (called CTestClass) within which I have a method (Foo). This method has the following signature: Foo(int x, int y, ref int z) I am attempting to use... |
|
|
All times are GMT. The time now is 09:27 AM. | Privacy Policy
|