user193442 user193442 - 9 months ago 43
C# Question

"where" keyword in class declaration in c sharp

Could anyone help me with the line

where TEntity : class, IEntity, new()
in the following class declaration.

public abstract class BaseEntityManager<TEntity>
where TEntity : class, IEntity, new()


where TEntity : ... applies constraints to the generic parameter TEntity. In this case, the constraints are:

class: The argument to TEntity must be a reference type
IEntity: The argument must be or implement the IEntity interface
new(): The argument must have a public parameterless constructor