Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
foreach (EndReasonEntity ere in ste.EndReason)
 {
   if (ere.Id == endReasonId)

 foreach (EndReasonActivityEntity erae in ere.EndReasonActivity)



in the above code the both ids match in the if condition , still it does not go in to the other foreeach loop which is right below it. instead it skips the whole loop ehy is that? i need a clear explanation please.
Posted
Updated 1-Nov-11 9:55am
v2
Comments
Tim Groven 1-Nov-11 13:57pm    
Does the ere.EndReasonActivity object actually have items in it? Usually only gets skipped if the array it's going through is empty.
Richard MacCutchan 1-Nov-11 14:23pm    
Use your debugger to step through the code and check the exact path it follows, and the values of all variables.

1 solution

First, how do you know it really skipped? You code sample is not complete, so I cannot see if your loops have any effect even if it is not skipped. So, use the debugger to say for sure. Now, check if and when ste.EndReason and ere.EndReasonActivity have any items. If you created the iterators their types by yourself, how do I know if the iterators are correctly implemented? So, again, run this under debugger to make sure.

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 1-Nov-11 14:43pm    
Good points :)
Sergey Alexandrovich Kryukov 1-Nov-11 15:05pm    
Thank you, Espen.
--SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900