-1

Lets say I have a c# class A which inherits from class B which in turn inherits from class C.

Class A : Class B
{}

Class B : Class C
{
    override OnIntialise()
    {
    do something else...
    }
}

Class C
{
    virtual Initialise()
    {
        OnIntialise();
    }
    virtual OnInitialise()
    {
        do something...
    }
}

Now when I call a.Initialise(), the program will call the method Initialise() defined inside Class C. Inside Initialise(), will the method OnIntialise() defined in Class C or Class B be invoked?

David
  • 9
  • 1
  • 3
  • _"will the method OnIntialise() defined in Class C or Class B be invoked?"_ -- what happened when you tried it? What didn't you understand about your _observed result_? Why are you asking the entire Stack Overflow community to weigh in on something you could easily just test yourself? – Peter Duniho Jan 03 '18 at 06:00

1 Answers1

0

Initialise method of class B will be called in this case as it is being overridden in the child class i.e. class B. Had this method been overridden in class A then method in class A would have got called.

Yogi
  • 9,174
  • 2
  • 46
  • 61