More trivia than really important: Why no new() constraint on Activator.CreateInstance<T>() ?
- by flq
I think there are people who may be able to answer this, this is a question out of curiosity:
The generic CreateInstance method from System.Activator, introduced in .NET v2 has no type constraints on the generic argument but does require a default constructor on the activated type, otherwise a MissingMethodException is thrown. To me it seems obvious that this method should have a type constraint like
Activator.CreateInstance<T>() where T : new() {
...
}
Just an omission or some anecdote lurking here?