泛型
泛型是一个比较有用的东西,至少在go中大家都在吐槽,学完后发现也就这样,说明我以后还要继续加油看
泛型没有可以,有了更好
泛型基本上就是一个模板的意思,网上许多的例子上都是这样的,int,string
基本上在日常工作中用不到,但是你需要了解一下
泛型类,和普通类差一个T
class x<T>
{
}
约束
class x<T> where T:条件//struct、class、
{
}
泛型接口的静态成员
xxx<T> {
static int q
}
不同的T之间q不一样,
同样的T的不同实例,q也不一样
QQ<int> a = new QQ<int>();
a.a = 1;
QQ<int> b = new QQ<int>();
b.a = 2;
Console.WriteLine(a.a == b.a);
==out==
False