where T:new() 约束类型参数至少有一个无参构造函数
使用场景 : 无意中使用new T 引发了new() 约束的实际使用
例子:
private IEnumerable<T> FormatProductProcessDayOutputData<T>(IEnumerable<T> qry) where T : vw_ProductProcess_DayOutputData, new()
{
var list = qry.Select(x => new T
{
class_date = x.class_date,
D1_count = x.D1_count,
D234_count = x.D234_count,
D2_count = x.D2_count,
D3_count = x.D3_count,
D4_count = x.D4_count,
D5_count = x.D5_count,
is_social_security_card = x.is_social_security_card == "1" ? "社保" : "非社保"
});
return list;
}