title: Can you explain me this strange behaviour of c# with optional arguments?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8909811/c-sharp-optional-parameters-on-overridden-methods">C# optional parameters on overridden methods</a>  </p>
  </blockquote>
  
  
  
  <p>This is the output of the following code:</p>
  
  <pre><code>Peter: -1
  Peter: 0
  Fred: 1
  Fred: 1
  </code></pre>
  
  <p>Can you explain me why the call of Peter <code>p.TellYourAge()</code> and <code>p.DoSomething()</code> is not identical?</p>
  
  <p>Here the code to try it yourself (VS2010 and FW 4):</p>
  
  <pre><code>    static void Main(string[] args)
      {
          Peter p = new Peter();
          p.TellYourAge(); // expected -1, result: -1
          p.DoSomething(); // expected -1, result: 0
  
          Fred f = new Fred();
          f.TellYourAge(1); // expected 1, result: 1
          f.DoSomething(); // expected 1, result: 1
  
          Console.ReadKey();
      }
  }
  
  public abstract class Person
  {
      public abstract void TellYourAge(int age); // abstract method without default value
  }
  
  public class Peter : Person
  {
      public override void TellYourAge(int age = -1) // override with default value
      {
          Console.WriteLine("Peter: " + age);
      }
  
      public void DoSomething()
      {
          TellYourAge();
      }
  }
  
  public class Fred : Person
  {
      public override void TellYourAge(int age) // override without default value
      {
          Console.WriteLine("Fred: " + age);
      }
  
      public void DoSomething()
      {
          TellYourAge(1);
      }
  }
  </code></pre>