public void Request<T>(List<T> EntityList) where T : 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的接口
本文介绍了.NET中C#泛型的五种类型参数约束,包括必须为结构体、类、具备无参构造函数等,并提供了具体的代码示例。
2458

被折叠的 条评论
为什么被折叠?



