C# code confusion of where clause

前端 未结 1 1296
醉酒成梦
醉酒成梦 2021-01-12 06:08
public interface ICrudService where T: Entity, new()

What is the meaning of \"new()\" at the end of the above code?

1条回答
  •  执笔经年
    2021-01-12 06:19

    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 讨论(0)
提交回复
热议问题