Besides generic constraints expressed based on interfaces or base classes, a few other techniques are available. One is the
new constraint, expressing the requirement to have a default constructor available for a certain type parameter:
Obviously, the preceding
CreateInstance method doesn’t provide any value over direct instantiation of an object from the outside. It’s merely a way to show how the expected constructor syntax can be used in conjunction with a type parameter as long as that parameter is properly constrained. From the outside, this type would be used as follows:
It turns out the Int32 ...