I tried to google this, but all I could find was documents on ordinary class declarations.
public class DataContextWrapper<T> : IDataContextWrapper where T : DataContext, new()
{
}
I see that the class implements IDataContextWrapper, inherits from DataContext and varies with type T depending on how it is instantiated.
I don’t know what “where T” or the “, new()” might mean.
It’s a generic constraint and restricts what types can be passed into the generic parameter.
In your case it requires that
Tis indentical to or derived fromDataContextand has a default(argumentless) constructor(thenew()constraint).You need generic constraints to actually do something non trivial with a generic type.
new()constraint allows you to create an instance withnew T().DataContextconstraint allows you to call the methods ofDataContexton an instance ofTMSDN wrote: