Hello,
I have a linked list (q1) of type Report, where Report is a bespoke class.
I need to enumerate the linked list, and I understand the c#2.0 way of doing this is as follows.
foreach (Report r in q1)
{
}
It compiles ok, but at run time I get an exception thus :
"Collection was modified after the enumerator was instantiated."
I have googled this to death, and the best I could come up with was to add the following to lines to the start of the code block
IEnumerator<Report> e = q1.GetEnumerator();
e.Reset();
Neither e.Reset() nor e.MoveNext() works yet other people say it does. I am confuzzed. Is this a c# bug? Or more likely I'm doing something wrong.
I am coming to c# as a noob, with Java experience. Can anyone help?
I have a linked list (q1) of type Report, where Report is a bespoke class.
I need to enumerate the linked list, and I understand the c#2.0 way of doing this is as follows.
foreach (Report r in q1)
{
}
It compiles ok, but at run time I get an exception thus :
"Collection was modified after the enumerator was instantiated."
I have googled this to death, and the best I could come up with was to add the following to lines to the start of the code block
IEnumerator<Report> e = q1.GetEnumerator();
e.Reset();
Neither e.Reset() nor e.MoveNext() works yet other people say it does. I am confuzzed. Is this a c# bug? Or more likely I'm doing something wrong.
I am coming to c# as a noob, with Java experience. Can anyone help?