I think my code is self explanatory about what i want to achieve :
private bool Comparison<T>(T operatorOne, T operatorTwo, string operand)
{
switch (operand.ToLower())
{
case "=":
return operatorOne.Equals(operatorTwo);
case "<":
return operatorOne < operatorTwo;
case ">":
return operatorOne > operatorTwo;
case "contains":
return operatorOne.ToString().Contains(operatorTwo.ToString());
default:
return false;
}
}
It gives me error :
Error 16 Operator '>','<' cannot be applied to operands of type 'T' and 'T'
I need a method that can compare strings, Int,Double, chars. Note: Exclude the condition that strings will be passed for > or < check OR Int will be sent for "contains" check