title: Default Interface Methods in C# 8
body: <p>Consider the following code example:</p>
  
  <pre><code>public interface IPlayer
  {
    int Attack(int amount);
  }
  
  public interface IPowerPlayer: IPlayer
  {
    int IPlayer.Attack(int amount)
    {
      return amount + 50;
    }
  }
  
  public interface ILimitedPlayer: IPlayer
  {
    new int Attack(int amount)
    {
      return amount + 10;
    }
  }
  
  public class Player : IPowerPlayer, ILimitedPlayer
  {
  }
  </code></pre>
  
  <p>Using the code:</p>
  
  <pre><code>IPlayer player = new Player();
  Console.WriteLine(player.Attack(5)); // Output 55, --&gt; im not sure from this output. I can compile the code but not execute it!
  
  IPowerPlayer powerPlayer = new Player();
  Console.WriteLine(powerPlayer.Attack(5)); // Output 55
  
  ILimitedPlayer limitedPlayer = new Player();
  Console.WriteLine(limitedPlayer.Attack(5)); // Output 15
  </code></pre>
  
  <p>My problem is on the code: </p>
  
  <pre><code>Console.WriteLine(player.Attack(5)); // Output 55
  </code></pre>
  
  <p>The question is: The output should be <strong>15</strong> or <strong>55</strong>?!</p>
  
  <p>According to the .NET Team:</p>
  
  <p><a href="https://github.com/dotnet/csharplang/blob/master/proposals/default-interface-methods.md" rel="nofollow noreferrer">Decision: Made 2017-04-11: Runs I2.M, which is the unambiguously most specific override at runtime.</a></p>
  
  <p>I'm not sure here beacuse of the keyword 'new' on the overridden interface?what should be the correct behaviour?</p>
  
  <p>In case you need to compile it from source, you can download the source code from:
  <a href="https://github.com/alugili/Default-Interface-Methods-CSharp-8" rel="nofollow noreferrer">https://github.com/alugili/Default-Interface-Methods-CSharp-8</a></p>