using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp26
{
delegate T TestIout<out T>();
delegate void TestIn<in T>(T t);
interface Test<out T>
{
T TestFun();
}
class Father
{
}
class Son : Father
{
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("协变逆变");
TestIout<Son> os = () =>
{
return new Son();
};
TestIout<Father> of = os;
Father f=of();
TestIn<Father> iF = (value) =>
{
};
TestIn<Son> iS = iF;
iS(new Son());
}
}
}
C#中的协变和逆变