Преглед изворни кода

2004-11-25 Carlos Alberto Cortez <[email protected]>

	* List.cs: Enumerator changed to behave like the MS impl.
	

svn path=/trunk/mcs/; revision=36562
Carlos Alberto Cortez пре 21 година
родитељ
комит
b8aadf0280

+ 4 - 0
mcs/class/corlib/System.Collections.Generic/ChangeLog

@@ -1,3 +1,7 @@
+2004-11-25  Carlos Alberto Cortez <[email protected]>
+
+	* List.cs: Enumerator changed to behave like the MS impl.
+	
 2004-11-25  Ben Maurer  <[email protected]>
 
 	* Stack.cs: New, list based impl. Waiting for some gmcs fixes.

+ 7 - 8
mcs/class/corlib/System.Collections.Generic/List.cs

@@ -269,12 +269,11 @@ namespace System.Collections.Generic
 
 			public T Current {
 				get {
-					if (list.modified != modified)
-						throw new InvalidOperationException ();
 					if (current < 0)
-						current = 0;
-					if (current > list.count)
-						throw new ArgumentException ();
+						throw new InvalidOperationException ("Enumeration has not been initialized; call MoveNext first.");
+					if (current >= list.count)
+						throw new InvalidOperationException ("Enumeration already finished.");
+					
 					return list.contents [current];
 				}
 			}
@@ -288,16 +287,16 @@ namespace System.Collections.Generic
 			public bool MoveNext ()
 			{
 				if (list.modified != modified)
-					throw new InvalidOperationException ();
+					throw new InvalidOperationException ("List was modified while enumerating.");
 
 				current++;
 				return current < list.count;
 			}
 
-			public void Reset ()
+			void IEnumerator.Reset ()
 			{
 				if (list.modified != modified)
-					throw new InvalidOperationException ();
+					throw new InvalidOperationException ("List was modified while enumerating.");
 
 				current = -1;
 			}