In C# can you do something like
Func<typeof(variableType),int)> myDelegate;
where you can pass the type arguments dynamically to a delegate?
In C# can you do something like
Func<typeof(variableType),int)> myDelegate;
where you can pass the type arguments dynamically to a delegate?
You can not use Func<typeof(variableType),int)> myDelegate;
.and get syntax error.
Use:
Func<object,int> myDelegate;
or:
Func<dynamic,int> myDelegate;
And see this:Generating Delegate Types dynamically in C#
No. typeof() is evaluated at run-time. Your delegate declaration is evaluated at compile time. The typeof() evaluation would have to occur first for this to work.