tags:

views:

89

answers:

2

Hi! What does new() mean in the following context:

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

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.

Wyatt Barnett
+6  A: 

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

See Constraints on Type Parameters.

Mark Byers
why we want to impose that it has a parameterless constructor?
So that code can use `new TEntity()`
John Saunders