When should we use Action<T>
and not to define a delegate explicitly?
Thanks
When should we use Action<T>
and not to define a delegate explicitly?
Thanks
Well...
Action<T> is almost the same as delegate void (T t)
and
Func<T> is almost the same as delegate T ()
Action and Func (and lambdas) are just 'syntactical sugar' and a convenience for using delegates.
So it's really just a matter of preference.
It's entirely a matter of preference, but I see no reason to ever define your own delegate if one of the overloads of Action or Func will work. If you have a ref/out/params parameter, optional arguments, or some other such edge cases you have no choice but to define your own.