public static void Main() { var del = new StringDelegate(PrintString); var md = new MultiDelegates(); del += md.PrintStringLength; int result = del("Pesho"); Console.WriteLine(result); }
public static void Main() { var del = new StringDelegate(PrintString); var md = new MultiDelegates(); del += md.PrintStringLength; var result = del("Pesho"); Console.WriteLine(result); }
static void Main(string[] args) { MultiDelegates del = new MultiDelegates(DeleMethod1); // ONE WAY TO REGISTER DELEGATE del += DeleMethod2; // ANOTHER WAY TO REGISTER del += DeleMethod3; int returnedValue = del(5); Console.WriteLine($" returned value of delegate = {returnedValue}"); // it will return the last delegate DeleMethod3 Console.ReadKey(); }
public static void Main() { StringDelegate<string> d = MultiDelegates.PrintString; MultiDelegates instance = new MultiDelegates(); d += instance.PrintStringLength; d += delegate(string str) { Console.WriteLine("Uppercase: {0}", str.ToUpper()); return 3; }; int result = d("some string value"); Console.WriteLine("Returned result: {0}", result); }
public static void Main() { StringDelegate <string> d = MultiDelegates.PrintString; MultiDelegates instance = new MultiDelegates(); d += instance.PrintStringLength; //d += delegate(string str) //{ // Console.WriteLine("Uppercase: {0}", str.ToUpper()); // return 3; //}; d("some string value"); //Console.WriteLine("Returned result: {0}", result); }