kingBook

导航

C# List

List.Sort

List<int> list=new List<int>{2,3,5,1,4};

list.Sort((int a,int b)=>{
    return a-b;
});

string str="";
for(int i=0;i<list.Count;i++){
    str+=list[i].ToString();
}
Debug.Log(str);//output:12345
  • public void RemoveRange (int index, int count);
    移除从 index 索引开始(含 index),共 count 个元素
// public void RemoveRange (int index, int count);
// 移除从 index 索引开始(含 index),共 count 个元素
List<int> list = new List<int>{ 0, 1, 2, 3, 4 };
list.RemoveRange(2,3); 
for(int i = 0; i < list.Count; i++) {
    Debug.Log(list[i]);
}
// output: 
// 0
// 1

posted on 2021-02-22 11:59  kingBook  阅读(100)  评论(0编辑  收藏  举报