Real example of Func<sometype> + Func<sometype>

Lets say you have:

Func<string> a = () => "string here";
Func<string> b = () => "other string here";

var c = a + b;

What the realworld need for this?

Jon Skeet
people
quotationmark

The only time I can think of it being useful is if you're actually going to treat it as a list of delegates (via Delegate.GetInvocationList), and invoke each one separately. You could do that for validators, for example - where each validation step could return null for "valid" or an error message otherwise. It would be very rare to do so though.

The predominant usage for delegate combination is for event handlers - where usually the delegate type is compatible with EventHandler (with a void return type). At that point, the behaviour of multi-cast delegates returning the result of the last action invoked doesn't matter, as there's no return value anyway.

people

See more on this question at Stackoverflow