error handling - Is it possible to throw an exception using short hand condition operator? c# -
To throw an exception, I'm trying to use a short hand operator to check a condition.
Throw (Results == Wrong)? The new exception ("the result is false."): Faucet;
After the lines above the line above, I get an "unrequited code detected error".
I think if "not found, it is still throwing an exception."
Any better way to do this little hand?
As far as I know, you can not do this because you throw
is either an exception or a zero And in both cases the code below is not always available, you can do it on one line only:
If (! Result) throw a new exception ("the result is false." );
This also expands less typed characters
Comments
Post a Comment