DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Remove Some Items From ArrayList

02.02.2007
| 3928 views |
  • submit to reddit
        // removes some items from ArrayList

int count = myArrayList.Count;
for(int i=0; i<count;)
{
	myArrayListItem item = (myArrayListItem)myArrayList[i];
	if(myArrayListItem.MyPropery > someValue)
	{
		myArrayList.RemoveAt(i);
		count--;
	}else{
		i++;
	}

}