Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7707235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:18:30+00:00 2026-06-01T00:18:30+00:00

How do we call a virtual method from another method in the base class

  • 0

How do we call a virtual method from another method in the base class even when the current instance is of a derived-class?

I know we can call Method2 in the Base class from a method in the Derived class by using base.Method2() but what I want to do is calling it from the other virtual method in the Base class. Is it possible?

using System;

namespace ConsoleApplication1
{
  class Program
  {
    static void Main( string[] args )
    {
      Base b = new Derived(  );
      b.Method1(  );
    }
  }


  public class Base
  {
    public virtual void Method1()
    {
      Console.WriteLine("Method1 in Base class.");
      this.Method2( );   // I want this line to always call Method2 in Base class, even if the current instance is a Derived object.
      // I want 'this' here to always refer to the Base class. Is it possible?
    }

    public virtual void Method2()
    {
      Console.WriteLine( "Method2 in Base class." );
    }
  }

  public class Derived : Base
  {
    public override void Method1()
    {
      Console.WriteLine( "Method1 in Derived class." );
      base.Method1();
    }

    public override void Method2()
    {
      Console.WriteLine( "Method2 in Derived class." );
    }
  }

}

With the above codes, it will output:

Method1 in Derived class.
Method1 in Base class.
Method2 in Derived class.

while what I would expect is:

Method1 in Derived class.
Method1 in Base class.
Method2 in Base class.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:18:31+00:00Added an answer on June 1, 2026 at 12:18 am

    No you cannot do that, the purpose of virtual methods is that derived classes can override the implementation and that the implementation is used even when called from base classes.

    If that causes problems then the code you need to run should not be in a virtual method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that calling a virtual method from a base class constructor can be
I need to call a virtual method for all classes derived from a given
I have some code where I really want to call a virtual method from
Basically, I have a pure virtual class Base, and a concrete class Derived which
I have an abstract base class from which many classes are derived. I want
I'm getting a warning from ReSharper about a call to a virtual member from
I want a pure virtual parent class to call a child implementation of a
I know about the basic concept of virtual function and run-time call. But i
I call a javascript function from a textbox by using OnKeyPress=clickSearchButton() Here is my
I need to declare finalizing method finalize() for all descendants of the base class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.