What is the result of using the "as operator" on a null object?

c#

Solution

It would return null. The `as` operator's purpose is to avoid throwing an exception, per MSDN:

The as operator is like a cast operation. However, if the conversion isn't possible, as returns null instead of raising an exception.

For example:

object o = null; // also try with a string type
string result = o as string;
Console.WriteLine(result); // null

Problem

C# has the `as` keyword which can cast an object into something else, or fail and return null if it doesn't work. What happens if the value I try to as cast is null already? Do I get null out or does it throw some exception?

Original source