where T : class的含义

时间:2016-03-03 21:06:15   收藏:0   阅读:142
public class DbEntityEntry<TEntity> where TEntity : class

这是参数类型约束,指定T必须是Class类型。

 

.NET支持的类型参数约束有以下五种:
where T : struct                               | T必须是一个结构类型
where T : class                                | T必须是一个Class类型
where T : new()                               | T必须要有一个无参构造函数
where T : NameOfBaseClass          | T必须继承名为NameOfBaseClass的类
where T : NameOfInterface             | T必须实现名为NameOfInterface的接口

原文:http://www.cnblogs.com/dotnet-kpt/p/5239862.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!