Generics · interview question
What does the constraint where T : new() require?
Multiple choiceEasy
Answer and explanation
Correct answer
A. T must have a public parameterless constructor.
Why
new() lets generic code write new T(). It must be listed last when combined with other constraints.
References
Test yourself on Generics
A free test with instant, explained results. No account needed.