I know I can make a method like
private T MyFun<T>()
where T : IMyInterface
{...}
Can I do the reverse, i.e. where T does not implement IMyInterface? The specific use case is that I don’t want to allow nullables, but I’m curious just in general.
No, in the general case you cannot specify an “exclusion list”. However, to prevent Nullable types from being allowed, you can use the “where T : class” constraint. Because Nullable is a struct, that will have the desired effect.
Edit: Oops, it appears that I was too hasty – were you asking how to prevent anything that can be null, or specifically Nullable, from being allowed?