title: Is it possible to change the type used in a method of a base class from within a derived class without modifying the base class?
body: <p>Suppose we have four classes A, B, T and U, which look something like this:</p>
  
  <pre><code>using System;
  using bla;
  
  
  public class T
  {
      public void method()
      {
          Console.WriteLine("I am using T.");
      }
  }
  
  public class U : T
  {
      public new void method()
      {
          Console.WriteLine("I am using U.");
          // other stuff...
      }
  }
  
  public class A
  {
      public T t;
      public void method()
      {
          t = new T();
          t.method();
          // some important manipulations of t...
      }
  }
  
  namespace bla{
      using T = U;
      public class B : A
      {
          public new void method()
          {
              // now use type U instead of T in the base method.
              base.method();
              // other stuff...
          }    
      }
  }
  
  public class Test
  {
      public static void Main()
      {
          B b = new B();
          b.method();
      }
  }
  </code></pre>
  
  <p>I want to achieve that when the base method <code>base.method()</code> is called from within class B actually type U is used and not type T. Such that the output of the <code>Main()</code> method would be:</p>
  
  <pre><code>I am using U.
  </code></pre>
  
  <p>Is it possible to achieve this in C# <strong>without having to modify class A and/or T</strong>? Something like a using directive would be nice. The above code - obviously - doesn't work as I want. I also thought about using reflection, but I am not sure if it is possible to use reflection in this case without having to instantiate a new (anonymous) object or reference an existing one (both would not be nice in my case).</p>
  
  <p>Otherwise I would have to modify class A (resp. class B as an almost 100% line-by-line copy) by either substituting each T with U or by inserting a using directive at the beginning (or accepting parameters, or using templates, or whatever). Either way I would find this not very neat and I wonder if it is achievable somehow better.</p>
  
  <p>Am I missing something obvious?
  Thanks in advance for any help!</p>