Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Short way to add item after item in List?

Tags:

c#

.net

If there any short way besides foreach loop and new collection creation to add object after specific object in existing List ?

Just an example:

"amy","jerry","tony","amy","jack". I want to add "simon" after each "amy" in short way

like image 855
eugeneK Avatar asked Feb 27 '12 09:02

eugeneK


1 Answers

If you know where you want to enter an item, you can do

List.Insert(position, item)

See List.Insert() on MSDN

like image 81
Darren Young Avatar answered Sep 18 '22 05:09

Darren Young