where子句中的C#代码混淆 [英] C# code confusion of where clause
本文介绍了where子句中的C#代码混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public interface ICrudService<T> where T: Entity, new()
什么是新的含义()
在上面的代码的结束?
What is the meaning of "new()
" at the end of the above code?
推荐答案
新()
表示 T
必须有一个无参数的构造函数。
new()
means that T
has to have a parameterless constructor.
这是一个帮助,使您能够构建在您的泛型类/方法键入 T
的对象:
This is a help to enable you to construct objects of type T
in your generic class/method:
public T Create()
{
return new T();
}
这篇关于where子句中的C#代码混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文