[Mono-list] Please help me with polimorfism, etc. (possible bug in the compiler?)
RoBiK
robik@mailbox.sk
Thu, 23 Sep 2004 12:27:09 +0200
Hi Roberto!
Your code has nothing to do with polymorphism. What you do is called
"hyding".
Please read this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html
/vclrfcsharpspec_3_7_1.asp
Anyway, in your example, you can never get different output form
this.GetType() and o.GetType() because both this and o point to the same
instance.
Robert
-----Original Message-----
From: mono-list-admin@lists.ximian.com
[mailto:mono-list-admin@lists.ximian.com] On Behalf Of Roberto Jimeno
Sent: Donnerstag, 23. September 2004 07:27
To: mono-list@lists.ximian.com
Subject: [Mono-list] Please help me with polimorfism, etc. (possible bug in
the compiler?)
Please help me monoers,
some days ago I was overriding Object's Equals() when I came across what I
thought to be a bug. Now I think I'm simply being confused about
inheritance, polimorfism, substitutability principle and such. Please
compile and execute the small example (attached file). You will see the
string:
"Types of self and argument are derivedClass and derivedClass respectively."
, while I was expecting to see
"Types of self and argument are derivedClass and baseClass respectively."
Can you tell me which changes (a suggestions is commented out in the
code) should I apply to my code in order to obtain the "baseClass"
expected result?
TIA