//ok
Action<int> CallbackWithParam1 = delegate { };
//error CS1593: Delegate 'System.Action<int>' does not take 0 arguments
Action<int> CallbackWithParam2 = () => { };
Just wondered why the discrepancy really. :-/
//ok
Action<int> CallbackWithParam1 = delegate { };
//error CS1593: Delegate 'System.Action<int>' does not take 0 arguments
Action<int> CallbackWithParam2 = () => { };
Just wondered why the discrepancy really. :-/
Jared is of course correct. To add a couple more details:
Action<int> c = => {};
??? I have no desire whatsoever to make =>
into a unary prefix operator.So on the one hand we have the list of pros:
and the cons:
If you were given that list of pros and cons, what would you do? I hope "implement the feature" would not be your choice; it was not ours.
It's essentially as simple as they are different features with different sets of supported scenarios. It's almost like asking
Why can lambdas be expressions but delegates can only be blocks?