Hi, if given two types (Type a, Type b), is there any "nice" way to find out if those two can be compared, summed etc.?
I was thinking if the types implement IConvertible
, one could convert
both to lets say decimal and perform a "Convert.ToDecimal(a) > Convert.ToDecimal(b)
" ?
I am building an expression evaluator and want to be able to work with any kind of object and thus need to know if a type can be compared to another type (it DOESN'T have to be the same types on both sides. eg. double > int
)