ArrayList - Move Item

  • Thread starter Thread starter Andrew Neillans
  • Start date Start date
A

Andrew Neillans

Hi all,

I have arraylist that contains a series of objects - I need to move one
object to another location in the list. What is the most efficient way
of doing this?

e.g.
ArrayList:
Item1
Item2
Item3

Move Item2 to the last position giving:

ArrayList:
Item1
Item3
Item2

Regards,

Andy Neillans
 
I have arraylist that contains a series of objects - I need to move one
object to another location in the list. What is the most efficient way
of doing this?

Why don't you start with the easiest way and see if it's efficient
enough for you? Something like

object item = yourArrayList[idx];
yourArrayList.RemoveAt(idx);
yourArrayList.Insert(newIdx, item);


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

array of ListViewItem - how to do it 6
Sum Values from different column 1
.NET syntax ?? 5
Regex items in any order 9
ListView Can't see column headers 2
Copy/Paste? 8
Union query 8
Help needed in Excel macro 1

Back
Top