c# - Comparison of various types -


i'm trying make code comparing 2 object in various types stored system.object.

i tried code:

object = getvalue(..); object b = getvalue(..); type t = findcommontype(a, b); return < b; 

the result of getvalue instance in 1 of following types: long, double, string, bool , my own class

method findcommontype returns instance of system.type, are:

  1. if actual type of passed arguments identical, returns typeof(a) in respect typeof(b).

  2. if types different, converts b typeof(a) , returns typeof(a).

  3. the returning instance of system.type 1 of following: typeof(long), typeof(int), typeof(double) , typeof(float).

for example, if a = (long)123 , b = "123", converts b long , returns typeof(long), code compares them.

but comparison a < b unsuccessful.

how can compare 2 objects in various types in respect type t holds?


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -