Range and Reverse: New LINQ extensions in .NET 6


var data = new[] { "person1", "person2", "person3", "person4", "person5" };
var getPerson3 = data.ElementAt(2); // forward take and count from index 0Output
var getPerson4 = data.ElementAt(^2); // revers take the second reversOutput
var get2PersonsAfterPerson2 = data.Skip(2).Take(2);Output 
person3 person4
var get2PersonsAfterPerson2New = data.Take(2..4);Output 
person3 person4
var get3PersonsReversFromPerson5 = data.Take(^3..);Output
person3 person4 person5



Maytham is a passionate software developer with more than ten years of experience. His motivation is to help transform ideas into production ready systems.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store