class Program
{
public delegate string MyDelegate();
static void Main(string[] args)
{
MyDelegate myDelegate = MyMethod1;
myDelegate += MyMethod2;
Console.WriteLine(myDelegate());
Console.ReadKey();
}
public static string MyMethod1()
{
Console.WriteLine("Mythod1");
return "Done";
}
public static string MyMethod2()
{
Console.WriteLine("Mythod2");
return "Done";
}
}
===========================================================
以上是目前自己在練習Delegate觀念時打的程式碼
想請問各位大大這段程式碼的結果為何是印出
MyMethod1
MyMethod2
Done
而不是
MyMethod1
MyMethod2
Done
Done
謝謝大家