protected void Page_Load(object sender, EventArgs e)
{
Cat cat = new Cat();
cat.Name = "Lily";
Pet<Cat> pet = new Pet<Cat>();
pet.T1 = cat;
Response.Write(pet.T1.Name);//输出了Lily
}
public class Cat
{
public string Name;
}
public class Pet<T>
{
private T _t;
public T T1
{
get
{
return _t;
}
set
{
_t = value;
}
}
}
.Net泛型简介
最新推荐文章于 2023-06-08 20:45:23 发布