Click here to Skip to main content
15,913,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to set an item of a List<> to the first location?

e.g.

C#
List <int> list = new List<int>

list.Add(10);
list.Add(20);
list.Add(30);
list.Add(40);


How to set the value 30 to the first postion in the list?
Posted
Updated 1-Sep-10 7:19am
v2

1 solution

One of the following depending on whether you want to replace or insert.

list[0] = 30;
list.Insert(0, 30);

Alan
 
Share this answer
 
Comments
Toli Cuturicu 2-Sep-10 7:47am    
I think the OP wants to "move" the 30 in the first place.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900