Cannot convert lambda expression to type ‘object’ because it is not a delegate type

Best would be to have the dictionary strongly typed, but if you assign the lambda to a specific lambda (delegate) first, it should work (because the compiler then knows the delegate format):

Action<bool> inp = InProgress => base.InProgress = InProgress;
dict.Add("InProgress", inp);

Or by casting it directly, same effect

dict.Add("InProgress", (Action<bool>)(InProgress => base.InProgress = InProgress));

Of course having such a dictionary format as object is discussable, since you’ll have to know the delegate format to be able to use it.

Leave a Comment

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