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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:53:07+00:00 2026-06-01T05:53:07+00:00

I have simplified my code to this internal class Program { private static void

  • 0

I have simplified my code to this

 internal class Program
{
    private static void Main(string[] args)
    {
        Child d = new Child();
        int i = 100;
        d.AddToTotal(i);

        Console.ReadKey();
    }

    private class Parent
    {
        public virtual void AddToTotal(int x)
        {
            Console.WriteLine("Parent.AddToTotal(int)");
        }
    }

    private class Child : Parent
    {
        public override void AddToTotal(int number)
        {
            Console.WriteLine("Child.AddToTotal(int)");
        }

        public void AddToTotal(double currency)
        {
            Console.WriteLine("Child.AddToTotal(double)");
        }
    }
}

The issue is that this calls

public void AddToTotal(double currency)

although I am calling it with an int and it should be using

public override void AddToTotal(int number)

Using the parent returns the expected result.

 Parent d = new Child();
 int i = 100;
 d.AddToTotal(i);

Update:

Thanks to @Jan and @azyberezovsky for pointing me to the specification. I have added a virtual empty method to the base class to get around this for now.

  • 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-01T05:53:09+00:00Added an answer on June 1, 2026 at 5:53 am

    A member lookup of a name N in a type T is processed as follows:

    First, the set of all accessible members named N declared in T and the base types of T is constructed. Declarations that include an override modifier are excluded from the set. If no members named N exist and are accessible, then the lookup produces no match, and the following steps are not evaluated.

    Thus when you use variable of Child type

    Child d = new Child();
    int i = 100;
    d.AddToTotal(i);
    

    method public override void AddToTotal(int number) is excluded from set, and we have only one method with name N left. Int is converted implicitly to double, so no errors occured.

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

Sidebar

Related Questions

I have a class with a few simple structs like this (simplified code) inside
I have this simplified code: <div class=container> <input type=submit name=submit class=submit value=Sign Up> </div>
I have code like this (simplified): def outer(): ctr = 0 def inner(): ctr
I have this code (which is way simplified from the real code): public interface
I have this code and cannot figure out how it could be simplified via
I am customizing my table cells. I have this code (simplified) which is giving
I have a following (simplified) code: var myModule = { submitDummyForm: function(){ console.log(this); //
I have 3 django models (simplified for this example): class Fighter (models.Model): name =
I have a fairly simple Linq query (simplified code): dim x = From Product
Imagine I have the following code (simplified regarding my real context of course): <div

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.