c# - What is the purpose of new() while declaration of a generic class? -
what purpose of new() while declaration of baseentitycollection class?
if i'm going remove it, got error following message "t must non-abstract type public parameterless constructor in order use parameter ..."
public abstract partial class baseentitycollection<t> : list<t> t : baseentity, new()
it means whatever class specify t
, has default (no parameters) constructor.
therefore, in generic class, can new t()
, create new object of type t.
Comments
Post a Comment