<T> where T : class,new ()

public interface IRepository<T> where T : class,new ()
{
bool AddEntity(T entity);
bool UpdateEntity(T entity);
bool DeleteEntityById(object id);

IList<T> GetAllEntities();
/// <summary>
/// 分页获取实体记录
/// </summary>
/// <param name="whereLabda"></param>
/// <param name="pageSize"></param>
/// <param name="pageIndex"></param>
/// <returns></returns>
IList<T> GetPageEntities(Func<T, bool> whereLabda, int? pageSize, int? pageIndex);
IList<T> GetEntities(Func<T, bool> whereLabda);

}

<T> where 的作用是说明T是泛型的,where是用来约束泛型T的;

T : class,new ()这名的意思是T是一个类且有一个空的构造函数

原文地址:https://www.cnblogs.com/xjt360/p/3660160.html