泛型类与非泛型类的区别有什么区别? [英] What is the difference between generic classes and their non generic counterpart?
本文介绍了泛型类与非泛型类的区别有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里有两个类:
class ProductProcessor
{
public Product ExtendName(Product p)
{
p.name = p.name + " The product";
return p;
}
}
class ProductProcessor<T> where T : Product
{
public T ExtendName(T p)
{
p.name = p.name + " The product";
return p;
}
}
如果两个类都没有性能损失,那么泛型类的优势是什么?
what is the advantage of the generic class given that both classes have no performance penalties?
推荐答案
https://www.codeproject.com/Articles/814768/CRUD- Operations-Using-the-Generic-Repository-Patte
https://www.codeproject.com/Articles/814768/CRUD-Operations-Using-the-Generic-Repository-Patte
通用存储库就是这样一种用法。
The generic Repository would be such a usage.
这篇关于泛型类与非泛型类的区别有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文