Traditional way of using Delegate
When we talk about delegate, it is a class of reference type used to encapsulate named or anonymous methods. For creating delegate we write,

Now, using the delegate which is declared can be done as shown below:

Now C# had added a small wrapper to the delegate with the help of Action<in T> delegate.
Action<T>
This delegate was introduced in Framework 2.0. We can now use Action<in T> delegate to pass a method as a parameter without explicitly defining the delegate. The compiler will take care of it. This delegate can accept parameters but without a return type.

Call the delegate using act(4, 5)
Func< T, TResult>
This was introduced in Framework3.5. This delegate is different from Action<T> in the sense that it supports for return value.

To call this delegate we can use
Console.WriteLine(“Using Func<> :” + fn(6, 6));
As it is returning the value. Hope you got the difference.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

asmaa adelPosted Sep 19, 2020, 12:11 PM
Thanks , waiting ur next topic
Logesh PalaniPosted Feb 17, 2020, 12:09 AM
Clear, thanks
SubashPosted Sep 16, 2016, 1:14 AM
Nice