J_PT J_PT - 7 months ago 68
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.


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