Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

The goto-less goto!

5.00/5 (3 votes)
6 Apr 2011CPOL 7.9K  
bool bFailed = false; bFailed |= bFailed ? true : condition1; bFailed |= bFailed ? true : condition2; bFailed |= bFailed ? true : condition3; if( !bFailed ) { PerformActionOnAllSuccess(); ...
bool bFailed = false;
bFailed |= bFailed ? true : condition1;
bFailed |= bFailed ? true : condition2;
bFailed |= bFailed ? true : condition3;
if( !bFailed ) {
    PerformActionOnAllSuccess();
    DoNormalCleanup();

} else {
    DoFailedCleanup();

}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)