开发者

C# code confusion of where clause

开发者 https://www.devze.com 2023-02-20 19:56 出处:网络
public interface ICrudService<T> where T: Entity, new() What 开发者_Go百科is the meaning of \"new()\" at the end of the above code?new() means that T has to have a parameterless constructor.
public interface ICrudService<T> where T: Entity, new()

What 开发者_Go百科is the meaning of "new()" at the end of the above code?


new() means that T has to have a parameterless constructor.

This is a help to enable you to construct objects of type T in your generic class/method:

public T Create()
{
   return new T();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消