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
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
Depending on what version we're taking about here, you can :
LinkedList<YourObjectType> ListOfObjects=new LinkedList<YourObjectType>(YourObjectArray);
In .Net v2.0 or above:
Object[] myArray = new Object[] { 1, "Hello", 2, 3.0 };
LinkedList<Object> linkedList = new LinkedList<Object>(myArray);
You can replace Object
with the type of element that the array actually holds.
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();