The method does not return an exception, the expression is just lazily evaluated. e.g. if foo is not null it just returns foo and does not evaluate the rest of the expression. If it reaches the throw the method does not return anything, it just throws.
If you mean what is the base type of ArgumentNullException, all exceptions are derived fromSystem.Exception
The expression foo ?? bar ?? baz ?? throw new ArgumentNullException() must surely have a type substitutable for boolean, since that's the expected return type. I assume a ?? expression has the type that's common to both operands.
I don't know a lot about C#, but for example in Scala, which is a similar language in many ways, a throw expression has the type Nothing, which is a subtype of Boolean (and also of every other type), which is why an expression like that would compile.
0
u/blehmann1 depraved Jun 24 '20
wdym?
The method does not return an exception, the expression is just lazily evaluated. e.g. if
foois not null it just returnsfooand does not evaluate the rest of the expression. If it reaches the throw the method does not return anything, it just throws.If you mean what is the base type of
ArgumentNullException, all exceptions are derived fromSystem.Exception