Why is this if-statement not breaking out of the for-loop?
Posted on 2007-07-23
I have an if-statement that I want to break out of the for-loop, but it's breaking out of the whole try clause. Here is the C# code I'm testing:
foreach (string item in myArr)
if (item == "test")
I'm trying to break out of the for-lop if the condition matches to do the next item. I would imaging that the if-break would break out of the for-loop. But when I stepped thru it in debugger, it's actually breaking the whole try statement. What am I missing here?