Hi All,
I will explain my scnerio. I have a static generic class like this.
public static class Cls<T>
There is a generic function in this class like below.
public static void Foo<K>()
The purpose of this function is to create a lambda expression of the type
Action<T, K>
and store it in a class member variable for use in other functions. My problem is that I cannot access the
K
type out of the function scope. So that I cannot create a
Action<T, K>
type class member variable. I cannot change the class signature like
Cls<T,K>
because different
K
should be processed against a single
T
type.
One solution I found that the
Action<T, K>
type function can be stored in a non generic
Delegate
variable and use the
DynamicInvoke
to execute the function. It will work but the execution time of
DynamicInvoke
is more than I expect. Is there any workaround for this? Any help you can give will be greatly appreciated.
Thanks,
Thomas