So these two methods have the same signature but different constraints
public static void Method<T>(ref T variable) where T : struct { }
public static void Method<T>(ref T variable) where T : class { }
But they cannot be defined in a single class because they have the same signatures. But in this particular case they’re mutually exclusive. (Unless I’m wrong about that)
I understand you can put additional constraints besides class and struct but you can’t specify both struct and class on the same method. So why would this fail to compile?
The generic constraints are not considered part of the method signature (thanks @Anthony for the link).
As far as the compiler is concerned you have a duplicate method – same numbers and types of parameters.