How to call the grandparent's method

From: ad (ad_at_wfes.tcc.edu.tw)
Date: 01/24/05


Date: Mon, 24 Jan 2005 19:29:32 +0800

base only can call the parent 's method
The result of the example below is
I am Parent
I am Child

How can we call the grandparent's method in a inhreited class,

I want the result is

I am GrandParent
I am Child

--------------------------------------------------------------------------
using System;

class Test
{
static void Main()
{
Child aChild = new Child() ;
aChild.WhoAmI();
Console.Read() ;
}
}

class GrandParent
{

public virtual void WhoAmI()
{
Console.WriteLine("I am GrandParent");
}

}

class Parent : GrandParent

{

public virtual void WhoAmI()
{
Console.WriteLine("I am Parent");
}

}

class Child : Parent

{

public virtual void WhoAmI()
{
base.WhoAmI();
Console.WriteLine("I am Child");
}

}



Relevant Pages

  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)