none
Collection was modified; enumeration operation may not execute. RRS feed

  • Question

  • Getting this exception for the following code:

    privatestring Tags=null;

    privatestaticList<string> TagsCollection=newList<string>();

    static void main()

    {

    foreach (string temp in Tags.Split(';')) {

    TagsCollection.Add(temp);

    }

    if (SomeCollection.OfType<Somethingelse>()
    .Any(x => TagsCollection.Contains(x.tag, StringComparer.OrdinalIgnoreCase))) Console.Write(true);


    }

    I am trying to find cause for such an exception here. I suspect if it can only in multithreaded environment.

    Thanks for your help,

    Sowjanya




    Friday, July 12, 2019 9:03 AM

All replies