[Mono-bugs] [Bug 78954][Nor] New - Removing from List<T> during enumeration should fail
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Jul 26 11:01:50 EDT 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by scottell.lists at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=78954
--- shadow/78954 2006-07-26 11:01:50.000000000 -0400
+++ shadow/78954.tmp.29474 2006-07-26 11:01:50.000000000 -0400
@@ -0,0 +1,50 @@
+Bug#: 78954
+Product: Mono: Runtime
+Version: 1.1
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: scottell.lists at gmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Removing from List<T> during enumeration should fail
+
+Below is a simple program which enumerates through a List<int> and
+removes each object. This completes without exception on Mono, but
+MS.Net 2.0 throws an exception:
+
+Unhandled Exception: System.InvalidOperationException: Collection was
+modified;
+enumeration operation may not execute.
+ at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource
+resour
+ce)
+ at System.Collections.Generic.List`1.Enumerator.MoveNext()
+ at T.Main()
+
+I think Mono's behavior should be consistent with this. Here is the
+sample program:
+
+using System.Collections.Generic;
+
+public class T
+{
+ public static void Main ()
+ {
+ List<int> list = new List<int> ();
+
+ list.Add (0);
+ list.Add (1);
+ list.Add (2);
+
+ foreach ( int ii in list )
+ list.Remove (ii);
+ }
+}
More information about the mono-bugs
mailing list