In C#, Action
and Func
are function pointers, you can pass them around just like any other object and you invoke them in exactly the same way that you call other functions. Essentially Action<IEnumerable<Customer>, Exception>
means:
- A function which returns void, and accepts two parameters of types
IEnumerable<Customer>
and Exception
as an input.
This would be a compatible signature:
void DoStuff(IEnumerable<Customer> customer, Exception e) { ... }
Sometimes long generic signatures like the one you have can be cumbersome to work with, it can occasionally be nicer to move those params into a single object such as:
class CustomerContext {
public IEnumerable<Customer> Customers { get; set; }
public Exception Exception { get; set; }
}
At least then you can pass around an Action<CustomerContext>
, which can save some typing and sanity :)