I have method with two parameters: bool1 and bool2. Both are boolean of course. I have to handle in code every combination of these conditions. Is any better way to do it then using nested if / else :
if (bool1)
{
if(bool2)
{
}
else
{
}
}
else
{
if(bool2)
{
}
else
{
}
}
if (bool1 && bool2) { }
else if (bool1) {}
else if (bool2) {}
else {}
var bothAreTrue = bool1 && bool2;
if(bothAreTrue){
}else if(bool1){
}else if(bool2){
}else{ //none is true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With