RollerCosta
RollerCosta

Reputation: 5216

multiple if and a single else condition

I am having multiple if in my controller action

As mentioned below
if() { } if() { } if() { } if() { }
Now i want a single else (execute when all if condition fails..i.e false)

Upvotes: 0

Views: 860

Answers (2)

Vamsi
Vamsi

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

Petar Ivanov
Petar Ivanov

Reputation: 93080

bool failed = true;
if() { failed=false; } if() { failed=false; } if() { failed=false; } if(failed) {}

Upvotes: 6

Related Questions