bool contin = true;
while (contin)
{
contin = false; // very important
foreach(string invoice in findListBox.listBox2.Items)
{
if (listBox2.Items count changed)
{
contin = true;
break;
}
}
}
As Marinus said, this can be a very inefficient method. Us it only if
the count rarely changes. If the count is likely to change often, find a
different algorithm (one which doesn't involve foreach)
--
--
Truth,
James Curran
[erstwhile VC++ MVP]
Home:
www.noveltheory.com Work:
www.njtheater.com
Blog:
www.honestillusion.com Day Job:
www.partsearch.com
That doesn't really tell me anything...I know how to break from a
loop.
What
kind of loop do you put "around" the foreach loop?
Thanks,
Trint
--
Trinity Smith
c#/vb.Net Developer
EcoQuest, Intl.
:
You could use break to exit the foreach loop. Around the foreach
loop
you
could create a loop to restart the foreach loop. Be aware that this is
a
serious thread to hang up your application. Maybe you should
redesign
:
How can I reset the collections within a foreach to be read as a
change from
within the foreach loop then restart the foreach after collections
has
been
changed?
foreach(string invoice in findListBox.listBox2.Items)
{
listBox2.Items count changed, restart this foreach
}
Thanks for any help.
Trint