title: Interface inheritance and property hiding trouble
body: <p>I recently introduced an interface on a base class for unit-testing purposes and ran into a weird problem. This is the minimal reproducible scenario:</p>
  
  <pre><code>interface IBase
  {
      string Text { get; }
  }
  
  interface IChild : IBase
  {
  }
  
  class Base : IBase
  {
      public string Text { get { return "Base"; }}
  }
  
  class Child : Base, IChild
  {
      public new string Text { get { return "Child"; }}
  }
  
  static void Main(string[] args)
  {
      var child = new Child();
      Console.WriteLine(child.Text); // Outputs "Child"
      Console.WriteLine((child as Base).Text); // Outputs "Base"
      Console.WriteLine(((child as Base) as IBase).Text); // Outputs "Child"
  }
  </code></pre>
  
  <p>The output of the first two <code>Console.WriteLine</code> commands is logical, but I fail to accept the output of the last one, it even outputs <code>Child</code> when using a temporary variable of type <code>Base</code>. Can anyone explain what is happening here?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>By removing the interface <code>IChild</code>, <code>((child as Base) as IBase).Text</code> suddenly results in <code>"Base"</code>. Which makes me conclude that, as long as <code>Child</code> implements <code>IBase</code> (directly or through interface inheritance) the result will be <code>"Child"</code> instead of <code>"Base"</code>.</p>
  
  <p>This can get really tricky when you refactor a method in an other class to take an argument of <code>IBase</code> instead of <code>Base</code>, as it suddenly results in different behavior.</p>