As per the title, is it possible to declare type-negating constraints in c# 4 ?
I found my self trying to implement the same case mentioned in the comments:
void doIt(IEnumerable what) { }
void doIt(T whats) { }
I excepted the following code to reference the first method:
doIt(new List());
But it actually references the second one.
One solution is to cast the argument like this:
doIt(new List().AsEnumerable());
The cast could be hidden by another overload:
void doIt(List whats) {
doIt(whats.AsEnumerable());
}