Reputation: 5216
I am having multiple if in my controller action
As mentioned belowif()
{
}
if()
{
}
if()
{
}
if()
{
}
Now i want a single else (execute when all if condition fails..i.e false)
Upvotes: 0
Views: 860
Reputation: 4253
You can use a boolean variable as a flag and set it to true when a if condition is true then you can use that flag to check whether at-least one if block was a sucess
Upvotes: 5
Reputation: 93080
bool failed = true;
if() { failed=false; } if() { failed=false; } if() { failed=false; } if(failed) {}
Upvotes: 6