CSharp examples for Custom Type:delegate
Delegate objects can be composed using the "+" operator.
using System;/*from w w w .ja v a2s . co m*/ delegate int IntConverter(int n); class TestDelegate { static int num = 10; public static int AddNum(int p) { num += p; return num; } public static int MultNum(int q) { num *= q; return num; } public static int getNum() { return num; } static void Main(string[] args) { IntConverter nc; IntConverter nc1 = new IntConverter(AddNum); IntConverter nc2 = new IntConverter(MultNum); nc = nc1; nc += nc2; nc(5); Console.WriteLine("Value of Num: {0}", getNum()); } }