public void Anonymous_Functions() { // These are all same thing // Lambda syntax Func <string, string> func = (s) => $"Hello {s}"; Func <string, string> func2 = (s) => { return($"Hello {s}"); }; // Old-school delegate syntax (do not use) Func <string, string> func3 = delegate(string s) { return($"Hello {s}"); }; // In same case had to use delefate where amount of parameters was different // public delegate T Method(params object[] parameters); //var funcParams = delegate (params object[] s) { return $"Hello {s}"; }; // Or can just take reference to method Func <string, string> func4 = GetHelloText; // Hopefully some day compiler will get smart enough and we can just do this //var func = (s) => { return $"Hello {s}"; }; Trace.WriteLine(func("World")); Trace.WriteLine(func2("World")); Trace.WriteLine(func3("World")); Trace.WriteLine(func4("World")); var sayer = new HelloSayer(func); string text = sayer.Say("World"); var sayer2 = new HelloSayer((s) => $"Not {s}"); string text2 = sayer2.Say("Nice"); Trace.WriteLine(text); Trace.WriteLine(text2); }
public abstract void sayHelloUsing([Ice.AsProxy] HelloSayer hs, string who);
public override void sayHelloUsing([Ice.AsProxy] HelloSayer hs, string who) { Console.WriteLine("HelloReceiver.sayHelloUsing start"); hs.sayHello(who); Console.WriteLine("HelloReceiver.sayHelloUsing done"); }