Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach (string s in listBox1.Items)
- {
- MessageBox.Show(s);
- //do stuff with (s);
- listBox1.Items.Remove(s);
- }
- listBox1.BeginUpdate();
- try {
- for(int i = listBox1.Items.Count - 1; i >= 0 ; i--) {
- // do with listBox1.Items[i]
- listBox1.Items.RemoveAt(i);
- }
- } finally {
- listBox1.EndUpdate();
- }
- List<string> removals = new List<string>();
- foreach (string s in listBox1.Items)
- {
- MessageBox.Show(s);
- //do stuff with (s);
- removals.Add(s);
- }
- foreach (string s in removals)
- {
- listBox1.Items.Remove(s);
- }
- while (listBox1.Items.Count > 0)
- {
- string s = listBox1.Items[0] as string;
- // do something with s
- listBox1.Items.RemoveAt(0);
- }
- for (int i = 0; i < listBox1.Items.Count; ++i)
- {
- // ...
- listBox1.Items.RemoveAt(i--);
- }
- for i as integer= list.items.count-1 to 0 step -1
- ....
- list.items.removeat(i)
- next
- for (var i == list.Items.Count - 1; i >= 0; i--)
- {
- list.Items.RemoveAt(i);
- }
- foreach(var s in listBox1.Items.ToArray())
- {
- MessageBox.Show(s);
- //do stuff with (s);
- listBox1.Items.Remove(s);
- }
Add Comment
Please, Sign In to add comment