I have a simple question. if we cast some null variable to a type. I expect compiler to throw Some Exception, but it is not. And I realy want to know the reason why. I mean
string sample1 = null as string;
string sample2 = (string)null;
object t1 = null;
TestClass t2 = (TestClass)t1;
maybe in the first one, as operator handles the exception handling. But others samples must throw exception. How compiler handles these situations , maybe since the variables are null , it does not perform cast operation? Cause if it really cast a null pointer it must be an error.