c# - Simplify nested loop logic -


i having trouble trying simplify logic contained in nested loops

i have provided pseudo code below, basics of i'm dealing with. actual code more complex , contains multiple nested loop structures.

i'm in charge of maintaining code, i'm not original writer of it

would place goto valid.

while(condition) {   while(conditition2)   {     if(condition3)       break condition2      if(condition4)       break condition   } } 

there many complexities preforming these code breaks.

i not allowed use goto, think easier solution trying do. should try , justify use of goto in case. thanks

prashant :)

you're setting messy , complicated code. consider linq if possible (loops practically code smell these days, complicated ones), otherwise consider refactoring inner loop separate method , using return;.

edit: great post eric lippert critiquing various alternatives problem: http://blogs.msdn.com/b/ericlippert/archive/2010/01/11/continuing-to-an-outer-loop.aspx


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -