Does anybody know how to dynamically create a Func<T>
instance?
//Create the Func type
Type funcType = typeof(Func<>).MakeGenericType(typeof(string));
//How do I pass a reference to the anonymous method?
Activator.CreateInstance(funcType, () => "test");
This does not compile:
Cannot convert lambda expression to type
object[]
because it is not a delegate type
Anyone?