title: Cast null value to a type
body: <p>If we cast some null variable to a type, I expect the compiler to throw some exception, but it doesn't. Why?</p>
  <p>I mean</p>
  <pre class="lang-cs prettyprint-override"><code>string sample1 = null as string;
  string sample2 = (string)null;
  
  
  object t1 = null;
  TestClass t2 = (TestClass)t1; 
  </code></pre>
  <p>maybe in the first one, the <code>as</code> operator handles the exception handling. But the others examples must throw exception. How does the compiler handle these situations? Maybe since the variables are null, it does not perform a cast operation? Cause if it really casts a null pointer, it must be an error.</p>