What are Func, Predicate, Action delegates with Examples ? #AspNetInterviewQuestionsSeries
Keeping the power of delegates in the mind .Net Framework has introduced the predefined delegates which can be useful for a developer. .Net Framework has also used these predefined delegates at many places e.g LINQ.
Action Delegate: As its name is ACTION this delegate ensures to performs actions and does not return anything. Action Delegate can take upto 16 parameters and returns nothing as they are void delegates and their primary task to perform some action. You can create Action in C# :
// define action Action<string> myAction; // F12 definition will be of your action, it can go upto 16 parameters public delegate void Action<in T>(T obj);
Example : they are most commonly getting used in List<T>.ForEach like functions.