开发者

What does new() mean in this context [duplicate]

开发者 https://www.devze.com 2023-01-15 10:51 出处:网络
This question already has answers h开发者_如何学运维ere: What does new() mean? (3 answers) Closed 10 months ago.
This question already has answers h开发者_如何学运维ere: What does new() mean? (3 answers) Closed 10 months ago.

What does new() mean in the following context:

 public interface ISpecification<TEntity>
        where TEntity : class,new()


It is a constraint on the type parameter TEntity that specifies that it must have a public parameterless constructor.

See Constraints on Type Parameters.


It means you can construct the class with a parameterless public constructor. Or, it lets you do var entity= new TEntity(); without the compiler having fits.

0

精彩评论

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