ASP.NET泛型List的各种用法Skip、Take等

mac2022-06-30  23

List在.NET里面使用得非常频繁,但有好多人不了解它各种小用法。我就一直记不大住...

asp.net中List的简单用法,例如:

1 2 3 4 5 6 7 List< int > list =  new  List< int >(); //新增数据 list.Add(123); //修改数据 list[0] = 345; //移除数据 list.RemoveAt(0);

程序里主要是对List对象的各种操作,例如排序,截取(跳过,取区间等)。用法如:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 //list的排序  list.Sort();  //list的遍历  foreach ( int  i  in  list)       strTest=i.ToString();  //list找出一个int类型数据 list.Find(); //找出多个int类型的数据 List< int > listnew = list.FindAll(..) //判断是否存在 list.Exist(); //截取(取前10条数据) list.Take(10); //截取(跳过前10条数据) list.Skip(10);

List分页,截取第3页的数据,即页码为31-41的数据(pagesize=10):

1 list.Ship(30).Take(10);

转载于:https://www.cnblogs.com/c-x-a/p/6179323.html

最新回复(0)