"csharpula csharp" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I am trying to iterate through list:
>
> foreach (classA objectA in listA)
> {
> //if there is no objectA with specific name in list A then:
>
> listA.add(objectA)
>
> }
>
> But it seems like this is an exception to modify the collection that I
> am iterationg through. How to solve this?
>
> Thank you!
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
I hope I understand you correctly.
You want to add an item to a collection if it is not already there?
Depending on the size of your list and the frequency of the search, you
could be adding unnecessary overhead to your application.
Have you considered using a collection type that does not allow duplicates?
http://msdn.microsoft.com/en-us/libr...s.generic.aspx