There is an AuthenticationBase
class in WCF RIA Services. The class definition is as follows:
// assume using System.ServiceModel.DomainServices
It means that a type used to fill the generic parameter T
must have a public and parameterless constructor. If the type does not implement such a constructor, this will result in a compile-time error.
If the new()
generic constraint is applied, as in this example, that allows the class or method (the AuthenticationBase
class in this case) to call new T();
to construct a new instance of the specified type. There is no other way, short of reflection (this includes using System.Activator
, to construct a new object of a generic type.