I've made a simple test :
object t = 3; object aa = 3; #1 Console.WriteLine(t.Equals(aa)); #2 Console.WriteLine(t.Equals(3)); #3 Console.WriteLine(3.Equals(aa)); All of them are true.(that's my problem actually).
looking at object , this is the used function:
public virtual bool Equals(object obj); The equals is virtual. so it can be overridden.
But I don't see any polymorphic behavior. this is just a pure boxed value.
Regarding line #1
t.Equals(aa)The reference type is the static type - Object.
so I thought it should call
Object.Equals: which means that the reference are different , meaning the first answer should beFalse.(and I probably wrong here). why is that?Regarding line #2
t.Equals(3)Again,
t'sstatic type is object. soObject.Equalsis running. how come it istrue?Regarding line #3
3.Equals(aa)I believe it is the
public override bool Equals(object obj);is running because the static type isint. and the param type is object. but why does ittrue? does it un-box the value ?
it seems that something , somehow unboxes the object without my notice :-(