J_PT J_PT - 1 year ago 103
C# Question

Base Class Generic Arguments Clarification

I have an Abstract class that is implemented like this:

public abstract class BaseImplementation<T, U> : IHistory<T>
where T : class, IEntity, new()
where U : DbContext, new()

I understand that the generic argument
is an EF
I understand that the generic argument
must be a class that implements the

What is the
Must be a new instance of a given class? What is the purpose of that?
Note that is declared in both

Thank you.

Answer Source

new() is a constraint specifying that the type argument must have a public parameterless constructor. For more information about the generic type constraint, see MSDN

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