Cannot convert from ‘method group’ to ‘System.Action’ error

DelegatedCall expects a delegate that takes any object as an argument. But your function foo1 that you are passing to DelegatedCall can only cope with a string argument. So, the conversion isn’t type-safe and thus is not possible.

Input parameters are contra-variant, but your code needs covariance. (See Difference between Covariance & Contra-variance.)

You can make DelegatedCall generic:

DelegatedCall<T>(Action<T> action)

…or have it take any delegate:

DelegatedCall(Delegate action)

But then implementing it is ugly and requires reflection. It also doesn’t verify that the function has only one parameter at compile-time.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)