How can I get the top 30 items in a list in C # and add it to a new list?
I have a list of about 1000 items and you want to create new lists of 30 items each, and then somehow bind the lists to a list
Use the LINQ Take() method:
LINQ
Take()
var top30list = source.Take(30).ToList();
Add using System.Linq to the top of the file to make it work.
using System.Linq
everyone says linq, so I will show an example without linq:
List<object> newList = new List<object>(); for(int i=0 ; i < 30 ; i++) newList.Add(oldList[i]);
newList.AddRange(list.Take(30));
Use Take (30)
public List<string> ReturnList(List<string> mylist,int page) { return mylist.Skip(30 * (page - 1)).Take(30) }
use orderby with the column name after that, using .Take(30) , select 30 items from the list.
orderby
.Take(30)
Source: https://habr.com/ru/post/951191/More articles:Play animated gif using libgdx - androidMedian of the median algorithm: why divide an array into blocks of size 5 - algorithmSelect all PNG images - htmlHow to return a module from expressions in f # - f #How can I implement XMPP for my own chat client? - javaConvert object to void * and vice versa? - chttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/951193/can-i-set-transient-properties-to-fetch&usg=ALkJrhgt2ad8Q0FJtdGLICqzlFXIVk8STQWhat is the alternative to a non-static initialization block? - javaEmbed a deferred object without using jquery - javascriptHow to hide dijit / form / button? - dojoAll Articles