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.