[Mono-dev] Fwd: List`1 IEnumerable constructor problem

Bas Westerbaan bas.westerbaan at gmail.com
Thu Aug 18 13:17:11 EDT 2005


I've checked the latest source code and it seems it has changed since the <> build and I assume the problem was solved.

Sorry for duplicate report,

---------- Forwarded message ----------
From: Bas Westerbaan <bas.westerbaan at gmail.com>
Date: Aug 18, 2005 7:10 PM
Subject: List`1 IEnumerable constructor problem
To: mono-devel mailing list <Mono-devel-list at lists.ximian.com>


This code creates a new list with the same elements as the first list by 
copying the elements from the first list by using the enumerator.
At least it should.

List<string> l1 = new List<string>(1);
l1.Add("A string");
List<string> l2 = new List<string>(l1);

Instead of creating a proper copy a NullReferenceException is thrown:

Unhandled Exception: System.NullReferenceException: Object reference not set 
to an instance of an object
in <0x00011> System.Collections.Generic.List`1<System.String>:Add (
System.String )
in <0x00067> System.Collections.Generic.List`1<System.String>:AddRange 
(IEnumerable`1 )
in <0x00019> System.Collections.Generic.List`1<System.String>:.ctor 
(IEnumerable`1 )
in <0x00045> Program:Main ()

I`m using mono <> compiled from source via Gentoo's 


Bas Westerbaan
GPG Public Keys: http://w-nz.com/keys/bas.westerbaan.asc 

Bas Westerbaan
GPG Public Keys: http://w-nz.com/keys/bas.westerbaan.asc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050818/b853a952/attachment.html 

More information about the Mono-devel-list mailing list