Consider the following alternatives:
Foo(someObj as SomeClass);
and
Foo((SomeClass)someObj);
Due to the fact that someObj is of the wrong type, the first version goes from null to Foo . After some time, this NullReferenceException . How much later? Depends on what Foo does. It can store null in the field, and then after a few minutes it gets access to some code that expects it to be non null .
But with the second version, you will immediately find the problem.
Why is it harder to fix errors?
Update
The OP asked in a comment: isn’t it easier to use as , and then check for null in the if ?
If null is unexpected and indicates an error in the caller, you can say:
SomeClass c = someObj as SomeClass; if (c == null) {
What are you doing in this if block? There are two general solutions. One of them is to throw an exception, so the responsibility of the caller must be related to their error. In this case, it is definitely easier to write:
SomeClass c = (SomeClass)someObj;
It just saves you the trouble of writing if / throw logic.
There is another alternative. If you have an implementation of the "stock" SomeClass , which you are happy to use where nothing is better (perhaps it has methods that do nothing or return "empty" values, etc.), you can do this:
SomeClass c = (someObj as SomeClass) ?? _stockImpl;
This ensures that c never null . But is it really better? What if the caller has an error; don't you want to help find errors? Changing the default object will mask the error. It sounds like an attractive idea until you spend a week in your life trying to track down a mistake.
(In a way, this mimics the behavior of Objective-C, in which any attempt to use the null link will never throw, it just does nothing.)