patterncsharpCritical
Func delegate with no return type
Viewed 0 times
withreturndelegatefunctype
Problem
All of the
Func delegates return a value. What are the .NET delegates that can be used with methods that return void?Solution
All Func delegates return something; all the Action delegates return void.
There's also
Func takes no arguments and returns TResult:public delegate TResult Func()Action takes one argument and does not return a value:public delegate void Action(T obj)Action is the simplest, 'bare' delegate:public delegate void Action()There's also
Func and Action (and others up to 16 arguments). All of these (except for Action) are new to .NET 3.5 (defined in System.Core).Code Snippets
public delegate TResult Func<TResult>()public delegate void Action<T>(T obj)public delegate void Action()Context
Stack Overflow Q#917551, score: 951
Revisions (0)
No revisions yet.