[Mono-bugs] [Bug 74675][Nor] New - Net 2.0 Generic List ToArray () doesn't work

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 20 Apr 2005 14:38:48 -0400 (EDT)


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 roosmaa@gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=74675

--- shadow/74675	2005-04-20 14:38:48.000000000 -0400
+++ shadow/74675.tmp.12283	2005-04-20 14:38:48.000000000 -0400
@@ -0,0 +1,47 @@
+Bug#: 74675
+Product: Mono: Runtime
+Version: unspecified
+OS: 
+OS Details: Ubuntu 5.04; Mono from svn HEAD
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: roosmaa@gmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Net 2.0 Generic List ToArray () doesn't work
+
+With .Net 2.0 the System.Collections.Generic.List<T>.ToArray () method
+throws an exception:
+Unhandled Exception: System.ArgumentException: An invalid argument was
+specified.
+in <0x0013c> System.Array:CopyTo (System.Array array, Int32 index)
+in <0x00038> System.Collections.Generic.List`1[System.Int32]:ToArray ()
+in <0x00068> Test:Main ()
+
+The previous exception was produced with the following code:
+--
+using System;
+using System.Collections.Generic;
+ 
+public class Test
+{
+        public static void Main ()
+        {
+                List<int> listofint = new List<int> ();
+                for (int i = 0; i < 10; i++)
+                        listofint.Add (i);
+                int[] arrayofint = listofint.ToArray ();
+                foreach (int i in arrayofint)
+                        Console.WriteLine ("Found: {0}", i);
+        }
+}
+--
+
+In Windows with MS NET (2.0) Framework this code works perfectly, but with
+Mono it throws that exception.