Note:
THIS IS NOT A DUPLICATE. This question asks why it is even possible to cast a null, my question is what is the difference between null
and (type)null
to begin with.
In this reference (from the MSDN C# reference), it is said that this code:
expression as type
is equivalent to this code ("except that the expression
variable is evaluated only one time"):
expression is type ? (type)expression : (type)null
It made me wonder, what's the point of the null casting? How is this different from:
expression is type ? (type)expression : null
Thanks!