Skip to content
Sharp

Generics · interview question

What does the constraint where T : new() require?

Multiple choiceEasy
Choose one answer
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.

Test yourself on Generics

A free test with instant, explained results. No account needed.

Start free test
All Generics questions →