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
谢谢大家