Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I transform or copy an array to a linked list?

I need to copy an array to a linked list OR transform the array in a linked list.

How this can be done in .NET (C# or VB)?

Thanks

like image 857
RHaguiuda Avatar asked Jul 02 '10 17:07

RHaguiuda


2 Answers

Depending on what version we're taking about here, you can :

LinkedList<YourObjectType> ListOfObjects=new LinkedList<YourObjectType>(YourObjectArray);
like image 163
Ian Jacobs Avatar answered Sep 20 '22 15:09

Ian Jacobs


To go to LinkedList from array:

var array = GetMyArray();
LinkedList<MyType> list = new LinkedList<MyType>(array);

To go to array from LinkedList:

var array = list.ToArray();
like image 45
Reed Copsey Avatar answered Sep 18 '22 15:09

Reed Copsey