Mid
From PDF
LINQ
LINQ
Find median salary (approx) s).ToList();?
Short answer: (salaries[salaries.Count / 2 - 1] + salaries[salaries.Count / 2]) / 2 : salaries[salaries.Count / 2]; var salaries = employees.Select(e => e.Salary).OrderBy(s => double median = salaries.Count % 2 == 0
Real-world example (ShopNest)
ShopNest builds a LINQ query for search filters, then calls ToListAsync() once in the repository—so the SQL runs one time, not inside a loop.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png