How to Insert any Item inside List at specified position?

 Posted by vishalneeraj-24503 on 12/19/2013 | Category: C# Interview questions | Views: 2276 | Points: 40
Answer:

With the help of Insert static function of List Collection,we can insert any item.

List<int> values = new List<int>();

values.Add("1"); //Output Would be:: 1
values.Add("3"); //Output Would be:: 1,3

values.Insert(1, "2"); //Output Would be:: 1,2,3


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response