using System;
using System.Text;
#region
class teach
{
public static teach print_t()
{
Console.WriteLine("Teach class");
return null;
}
}
class student : teach
{
public static student print_s()
{
Console.WriteLine("student class");
return null;
}
}
class TestClass
{
delegate void S_Del(student tec);
delegate teach T_Del();
public static void print(teach tec)
{
Console.WriteLine("逆变 student class");
}
public static void fun(student stu)
{
Console.WriteLine("逆变");
}
static void Main(string [] args)
{
//协变
T_Del del_t = student.print_s;
del_t();
del_t = teach.print_t;
del_t();
//逆变
S_Del del_s = print;
student stu = new student();
del_s(stu); //调用的时print函数
del_s = fun;
del_s(stu);//调用fun函数
Console.Read();
}
}
#endregion