In an If-Else Statement for a method return, should an Else be explicitly stated if it can instead b
Posted
by ccomet
on Stack Overflow
See other posts from Stack Overflow
or by ccomet
Published on 2010-04-20T16:07:02Z
Indexed on
2010/04/20
16:13 UTC
Read the original article
Hit count: 189
c#
|if-else-statement
I have a method that checks certain things and returns a Boolean based on those checks. It involves a single branching If section that checks about 5 conditions in sequence. If any of those conditions return true, then the method will return true;
. If none of the conditions return true, then the method will return false;
. Since the code after the If section will only run if none of the conditions are true, then that code is logically identical to including an actual Else statement.
So is it a better idea to actually write in the Else statement for this kind of situation?
© Stack Overflow or respective owner