CSharp examples for Custom Type:delegate
Implement delegate with a lambda expression
using System;//from www . j a v a 2 s. c o m using System.Collections.Generic; delegate int HandleTwo(int n, int m); class Program { static void Main(string[] args) { List<int> numbers = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; int[] numArray = numbers.ToArray(); List<string> words = new List<string> { "one", "two", "three", "four", "five" }; int result3 = Multiply(2, 3, (n, m) => n * m); Console.WriteLine("\tProduct of {0} * {1} is {2}", 2, 3, result3); } static int Multiply(int x, int y, HandleTwo proc) { if (proc == null) { throw new ArgumentNullException("Null delegate passed."); } return proc(x, y); } }