How to add item to the beginning of List?

前端 未结 5 1918
太阳男子
太阳男子 2020-12-04 08:17

I want to add a \"Select One\" option to a drop down list bound to a List.

Once I query for the List, how do I add my in

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 08:30

    Use Insert method of List:

    List.Insert Method (Int32, T): Inserts an element into the List at the specified index.

    var names = new List { "John", "Anna", "Monica" };
    names.Insert(0, "Micheal"); // Insert to the first element
    

提交回复
热议问题