定义:协变(out)和逆变(in)是用于接口和委托中修饰泛型的,定义泛型类型的使用区域。
语法:<out T>那么T的数据类型只能用于返回值。<in T>那么T的数据类型只能用于参数列表。
//自定义委托
public delegate Result Fun<in T, in K, out Result>(T t,K k);
internal class Mainclus
{
//定义函数
public static string Print(string str, char ch)
{
return str+ch;
}
internal static void Main(string[] args)
{
Fun<string,char,string> fun = Print;
Console.WriteLine(fun("hell",'o'));
}
}

事件:事件是基于委托的,简单理解为事件是一种更为安全的委托。
语法:访问修饰符 event 委托类型 事件名
特点ÿ








![Unity 从零开始的框架搭建1-2 事件的发布-订阅-取消的小优化及调用对象方法总结[半干货]](https://i-blog.csdnimg.cn/direct/b4e9d85f4a6945129c10eccb094ffeeb.png)










