using System;
namespace C14_6
{
public abstract class A
{
}
public class B : A
{
}
public class C : A
{
}
public class Test
{
//定義一個回傳型別是基底類別型的委派
delegate A TestA();
//定義3個回傳型別是衍生類別型的方法
public static B F()
{
return new B();
}
public static C F2()
{
return new C();
}
public static void Main()
{
//實例委派
TestA test1 = F;
TestA test2 = F2;
//單個叫用衍生型別成員
test1();
//整合委派
TestA test = test1 + test2;
//整合所有衍生型別的成員,進行叫用
test();
}
}
}
沒有留言:
張貼留言