Method Select
Select() Method
Let’s see a query to show only the student cities
List<Student> students = new List<Student>()
{
new Student("Sam","Mysore"),
new Student("Ted","Delhi"),
new Student("Sam","Bangalore"),
new Student("Raj","Mumbai"),
new Student("Adhin","Hyderabad"),
new Student("Raj","Indore"),
new Student("Bhuvan","Chennai"),
new Student("Sam","Banaras"),
};
var cities = students.Select(s=>s.City);
foreach (string c in cities)
Console.WriteLine(n);We can also select a property of each element!
SelectMany()
We can turn a two-dimensional array into a single sequence of values, as shown in this example
Last updated