user193442 user193442 - 1 year ago 82
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()

Answer Source

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download