Is there any way to get to the double "==" operator for a generic parameter? Note that .Equals does not work correctly in all cases.
Given:
bool MyMethod<T>(T left, T right)
{
return EqualityComparer.Default.Equals(left,right);
}
Then:
double a = double.NaN;
double b = double.NaN;
a == b; //returns false
MyMethod(a,b); //returns true
I'd like to get to the actual "==" operator for all types of T. Is that possible?
I have read Can't operator == be applied to generic types in C#? and it does not address my situation because the best answer suggests using EqualityComparer.Default but that does not return the mathematically correct value when comparing two double.NaN values.