[Code Snippet] Example of using Delegate, Func and Action side by side in C#
Quick and dirty example of using Delegate, Func and Action side by side in C# to show how to use function pointer or callback in C# Example #1 Delegate and Func side by side static int DoubleTheValue (int x) { return x * 2; } // delegate type should match the function signature - DoubleTheValue public delegate int functionDelegateType (int x); static void Method1 ( functionDelegateType func) { int doubleValue = func(5); } static void Method2 (Func<int, int> func) // easier syntax { int doubleValue = func(5); ...