Although I've looked through several of the answers regarding this question, I'm still not sure if I know what this line of code is doing:
public class SomeClass<P> : SomeInterface where P : AnotherInterface, new(){...}
What is new()
doing?
Although I've looked through several of the answers regarding this question, I'm still not sure if I know what this line of code is doing:
public class SomeClass<P> : SomeInterface where P : AnotherInterface, new(){...}
What is new()
doing?
While you usually see where T : Whatever[, Whatever2]
refer to other interfaces and classes, it can also be one of any of these constraints:
where T : struct
- T has to be a value typewhere T : class
- T has to be a reference typewhere T : unmanaged
- T and all of its variables have to be value types, as well as the variables those value types have... etc.where T : new()
- T has to have a parameterless constructor. This constraint must be specified last.where T : U
- T must be or derive from the argument supplied for U