How can I compare two nullable numbers of any type (int, decimal, float) and return a great of two
I tried this but it only works for integers
public static int? Compare(int? value1, int? value2)
{
if(value1> value2)
return value1;
return value2;
}
I tried this, but you cannot use > operator on operands of type T.
public static Compare<T>(T value1, T value2)
{
if(value1> value2)
return value1;
return value2;
}
Any ideas?