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 1031803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T13:59:14+00:00 2026-05-16T13:59:14+00:00

Is it possible to invoke method A.F() from instance of B class except of

  • 0

Is it possible to invoke method A.F() from instance of B class except of using refactoring. Thanks..


  class Program
  {
    public class A
    {
      public virtual void F()
      {
        Console.WriteLine( "A" );
      }
    }
    public class B : A
    {
      public override void F()
      {
        Console.WriteLine( "B" );
      }
    }

    static void Main( string[] args )
    {
      B b = new B();  

      //Here I need Invoke Method A.F() , but not overrode..      

      Console.ReadKey();
    }
  }
  • 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-05-16T13:59:14+00:00Added an answer on May 16, 2026 at 1:59 pm

    You may use the new keyword to have another definition of the same (named) method. Depending on the type of reference, you call A‘s of B‘s implementation.

    public class A
    {
      public void F()
      {
        Console.WriteLine( "A" );
      }
    }
    public class B : A
    {
      public new void F()
      {
        Console.WriteLine( "B" );
      }
    }
    
    static void Main( string[] args )
    {
      B b = new B();  
    
      // write "B"
      b.F();
    
      // write "A"
      A a = b;
      a.F();
    }
    

    If you feel that new is not the right solution, you should consider to write two methods with a distinguished name.


    Generally, you can’t call the base implementation from outside the class if the method is properly overridden. This is an OO concept. You must have another method. There are four ways (I can think of) to specify this distinguished method:

    • write a method with another name.
    • write a method with same name but another signature (arguments). It’s called overloading.
    • write a new definition of the method with the same name (use the new keyword) It’s called hiding.
    • Put it onto interfaces and implement at least one explicitly. (similar to new, but based on interface)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following method to invoke a class inside a jar file: invokeClass(path.to.classfile,
Say I have class B derived from class A Is it possible to invoke
In C++, you can invoke method's from a template argument like so: template<class T>
I'm just wondering if it's possible to invoke a method by reflection inside a
Is it possible to programmatically invoke default search functionality of IE using ASP.net ,
Possible Duplicate: Copy Constructor is not invoked # include <iostream> using namespace std; class
I can compile, get an instance and invoke a method of any C# type
I am trying to invoke an internal method from a dynamically generated one. The
in my application (using spring), i try to call a method from view using
Is it possible to somehow invoke a non-global function (i.e. a method of a

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.