Hi Mattias
Thanks for the reply, but I'm still lost. If I use the override on descendent class (for example, if I override the F method in B class), then when I try to invoke a typecast on a variable (the first 3 calls of the code. ie: a.F(), b.F()) the code will always execute the B.F() method, and descendent classes will lost the ability to "behave" as A class. I'm not very expericend with OOP (and for that, I might be saying a foolish here

) but isn't this "behave as" the polimorphic behavior
Also, the 10.5.3 Virtual methods C# language states:
"The most derived implementation of a virtual method M with respect to a class R is determined as follows:
- If R contains the introducing virtual declaration of M, then this is the most derived implementation of M.
- Otherwise, if R contains an override of M, then this is the most derived implementation of M.
- Otherwise, the most derived implementation of M with respect to R is the same as the most derived implementation of M with respect to the direct base class of R.
If I use the "new virtual" keywords, I keep the polimorphic behavior on the first 3 calls of my code, but 3 subsequent calls of G() all resolve to A.F(). In other words
class A
public void G(){this.F();
public virtual void F(){Console.WriteLine("A.F");
class B:A{ new public virtual void F(){Console.WriteLine("B.F");}
class C:B{ new public virtual void F(){Console.WriteLine("C.F");}
when I call
C c = new C()
A a = c
a.G()
the compiler should enter A.G, evalueate this.F(), found that F is virtual and the runtime type of the class is C (this = C) and then since C.F has the virual keyword, shouldn't it be resolved as the most derived method and takes place
Is it possible (and if so, how) to make the code below produces the following output
A.
B.
C.
A.
B.
C.
using System
class
public void G(){F();
public virtual void F(){Console.WriteLine("A.F");
class B:A { new public virtual void F(){Console.WriteLine("B.F");}
class C:B { new public virtual void F(){Console.WriteLine("C.F");}
class Class
[STAThread
static void Main(string[] args
C t = new C()
A a = t
B b = t
C c = t
// the first tree calls are ok with the C# language
// specification for "most derived implementation" rule (10.5.3 Virtual methods
a.F()
b.F()
c.F()
// The use of *this* pointer inside the G function
// breaks the most derived implementation rule
a.G();
b.G();
c.G();
Thanks again for the help. Cheers
Eric