muscha <mu****@no.spam.net> wrote:
What's the easiest way to convert List -> Array in c#? Say for example the
same thing like in Java:
List list = new ArrayList();
Item[] items = (Item[]) list.toArray(new Item[list.size()]);
Is there a way to do this?
Yes - and it's actually rather nicer in .NET/C#:
ArrayList list = new ArrayList();
....
Item[] items = (Item[]) list.ToArray (typeof(Item));
Note that it needs to be declared as ArrayList rather than IList, as
IList doesn't have the ToArray method, unfortunately.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too