title: Why does casting null to type for method selection work?
body: <p>According to the answer to <a href="https://stackoverflow.com/a/719566/1964861">C#: Passing null to overloaded method - which method is called?</a>, nulls seem to carry type information. In fact, I can also use</p>
  
  <pre><code>class Program
  {
      static void Method(TypeA a)
      {
          Console.Write("Output of Method(TypeA a):");
          Console.WriteLine(a); // Prints nothing, on account of the null.
      }
      static void Method(TypeB b)
      {
          Console.Write("Output of Method(TypeB b):");
          Console.WriteLine(b); // Also prints nothing, on account of the null.
      }
      static void Main()
      {
          var a = (TypeA)null;
          var b = (TypeB)null;
          Method(a);
          Method(b);
      }
  }
  class TypeA { }
  class TypeB { }
  </code></pre>
  
  <p>Which yields</p>
  
  <blockquote>
    <p>Output of Method(TypeA a):<br/> Output of Method(TypeB b):</p>
  </blockquote>
  
  <p>What's going on here? </p>