dcsimg
 

Submitted by: Srinath M S(srinath_ms@yahoo.com)

Tuesday Sep 17th 2019 by Srinath M S

Language: .NET, Expertise: Beginner - Learn how to use the OrderBy operator to pick a selected number of items in a given order.

Using the OrderBy operator in conjunction with Take in C#, we can pick a selected number of items based on an order.

int n = 3;
var firstThreeStates = states.OrderBy(s = s.population).Take(n);
Home
Mobile Site | Full Site