Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to delete the child nodes of a node. During the execution of the foreach loop I am having an error- "The element list has changed. The enumeration operation failed to continue." I think because I am changing the XMLfile I am having that error but dont know how to fix it. Can someone correct my code?
Posted

1 solution

This usually happens when you use foreach on your collections try using for instead.

Edit:
C#
foreach(var x in collection)
{
...
}
// becomes
for(int i=0;i<collection.length;i++)
{
...
}
 
Share this answer
 
v2
Comments
hatelove420 9-Feb-13 4:53am    
can u give me an example using of for
Mehdi Gholam 9-Feb-13 5:09am    
See the edited solution.
[no name] 9-Feb-13 5:13am    
http://www.codeproject.com/Questions/124184/The-element-list-has-changed-The-enumeration-opera

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900