Action and Func
Action and Func are delegate types.
The last parameter in a Func is the return type and the preceding types are the required parameters. If no return type is required (void) then Action should be used instead of Func -
In the above examples someFunc references a method that requires an int and string parameters and returns a decimal. someAction references a method that requires 2 string parameters and a bool parameter and returns void.
In the following code an array of numbers is created and used in 2 different function calls -
The problem is that these functions are very similar, the only difference being the condition in the if statement.
We would need to pass in a function as the parameter for the 2 methods.
In the above code the only differing parts of the previous 2 functions have been moved into their own functions (IsLargerThan10, IsEven).
A second parameter of type Func has been added to the main function to allow these functions to be passed in.