2
Reply

how to edit or modify a list collection which is iterating

Sudheer Kumar

Sudheer Kumar

Jan 6 2017 2:23 AM
317
i am having two list collections one for new persons and one for existing persons and my condition is if the record in new person matches with existing person it should remove the record from existing person for that i am using the following code
 
 foreach(var p in existingperson)
{
if(newperson.id==p.id)
{
 existingperson.remove(p);
return true;
}
else
{
return false;
}
}
 
its throwing an exception that i cant change collection in iteration.for using for loop i dont know the count of existing records..please help

Upload Source Code  Select only zip and rar file.
Answers (2)