Is it possible to check a condition is true for each line of a statement block without having if (condition)
before each line?
For example:
if (condition)
{
DoSomething();
DoSomethingElse();
DoAnotherThing();
}
At some point another background process may have set condition
to false before DoSomethingElse()
has been executed. Essentially I'm look for an efficient and easier way of saying:
if (condition) DoSomething();
if (condition) DoSomethingElse();
if (condition) DoAnotherThing();
In reality it's a long block of code, executed once, that I want to abandon if at any point a particular flag is changed.
What is the best way to tighten up this kind of code.