[Mono-dev] List`1 IEnumerable constructor problem
Bas Westerbaan
bas.westerbaan at gmail.com
Thu Aug 18 13:10:41 EDT 2005
Hello,
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 1.1.8.3 <http://1.1.8.3> compiled from source via Gentoo's
portage.
Regards,
Bas Westerbaan
http://blog.w-nz.com/
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/bc6a7600/attachment.html
More information about the Mono-devel-list
mailing list