Delegates vs Action, Func in C#

c#, delegates

Solution

None of the `Func` or `Action` types allow `out` or `ref` parameters, so you'll have to define your own delegates if you need to use those e.g.:

public delegate bool TryParse<T>(string s, out T value);

Problem

This might seem a silly question, but it's just for curiosity's sake. We have two particular already-defined delegates in C#: - `Action<T>` - `Func<T, TResult>` Action encapsulates any "void" method that takes 0 or more parameters. Func encapsulates any method that returns a specific value type and takes 0 or more parameters. My question is: in which cases it is recommended to define a custom delegate? Why would you need to do that? Thanks in advance

Original source

Related problems