how to get the top 30 items in a list

c#, list

Solution

Use `LINQ` `Take()` method:

var top30list = source.Take(30).ToList();

Add `using System.Linq` at the top of your file to make it work.

Problem

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 a 1000 items, and want to create new lists, of about 30 items each, and then somehow bind the lists to listbox

Original source

Related problems