Faced a problem I can not figure out how to solve, that is what is:
public class Info { public delegate string Method(int Value, string Name); public Method deleg; public Method deleg_1; public Info() { deleg = Quadratic_Equation; deleg_1 = Quadratic_Equation; deleg_1 += Cubic_Equation; } private string Quadratic_Equation(int a,string Name) { Console.WriteLine("1 метод"); return $"{Name} {a*a}"; } private string Cubic_Equation(int a,string Name) { Console.WriteLine("2 метод"); return $"{Name} {Math.Pow(a,3)}"; } }
I call this:
Info info = new Info(); Console.WriteLine(info.deleg(3,"Уравнение 1")); Console.WriteLine(info.deleg_1(3,"Уравнение 2")); Console.ReadKey();
How to correctly call delegate deleg_1
if I like Console.WriteLine(info.deleg_1(3,"Уравнение 2"));
That only displays the data of the last method that attached to the delegate, how to do it correctly, that would output the data from the 1 and 2 methods attached to the delegate? (