interesting boxing problem

  • Thread starter Thread starter cody
  • Start date Start date
C

cody

int a = 1;
short b = 1;
object o1 = a;
object o2 = b;
Console.WriteLine(o1.Equals(o2));

This returns false since the type a and b are not the same. But is there a
way the two objects behave like they would be not in boxed state?
How can I determine wheather 2 boxed objects are the same (It has to take
care of implicit boxing and integer promotion and so on)?
 
Hi
In such case you are limted by the amont of operations you can do on an
object ( which has only 4 member function) . so in such case you can just
compare there Tostring() values. using string comparison of the string
class.
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
Back
Top