Alright, I have the following code: (copied from my book).
class MyDelegate { public delegate void Func(string s); public void Show(string s) { Console.WriteLine("In MyD1: " + s); } } class Test { static void Show(string s) { Console.WriteLine("In test: " + s); } static void Main(string[] args) { MyDelegate md = new MyDelegate(); MyDelegate.Func f= new MyDelegate.Func(md.Show); MyDelegate.Func f1= new MyDelegate.Func(Show); f("hello"); f1("Hello"); f1 = f; f1("world"); } } The output is: In MyD1: hello In TestShow Hello InMyD1: world
Now, I didn't understand why the last line of the output is in "InMyD1" . because f1 delegate is called and not f.
Thanks in advance.
TestShowin your output, but you do not have it in your code.