Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
var distinctByDept = employees .Select(g => g.First()); What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainability, security, cost) When you would and would…
How to filter distinct objects by a property? var distinctByDept = employees .GroupBy(e => e.Department) .Select(g => g.First()); Explanation: Groups employees by department and selects one employee from each group…
Answer: var salaries = employees.Select(e => e.Salary).ToList(); double runningTotal = 0; var runningTotals = salaries.Select(s => runningTotal += s); What interviewers expect A clear definition tied to LIN…
How to calculate running totals using LINQ? var salaries = employees.Select(e => e.Salary).ToList(); double runningTotal = 0; var runningTotals = salaries.Select(s => runningTotal += s); foreach (var total in runni…
Answer: string searchName = "Alice"; var query = employees.AsQueryable(); query = query.Where(e => e.Name.Contains(searchName)); var result = query.ToList(); What interviewers expect A clear definition tied to LIN…
How to perform conditional LINQ queries? string searchName = "Alice"; var query = employees.AsQueryable(); if (!string.IsNullOrEmpty(searchName)) query = query.Where(e => e.Name.Contains(searchName)); var result = que…
Answer: var departmentsWithEmployees = new[] var allEmployees = departmentsWithEmployees .SelectMany(d => d.Employees); What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (perform…
How to flatten hierarchical data with SelectMany? var departmentsWithEmployees = new[] new { Department = "IT", Employees = new [] {"Bob", "Charlie"} new { Department = "HR", Employees = new [] {"Alice", "Eva"} } var all…
var groupJoin = from d in departments into empGroup What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainability, security, cost) When you would and would not use it…
How to group join with multiple collections? var groupJoin = from d in departments join e in employees on d.Name equals e.Department into empGroup select new { Department = d.Name, Employees = empGroup }; foreach (var gr…
int pageNumber = 2; int pageSize = 2; var page = employees What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainability, security, cost) When you would and would not…
How to use LINQ for paging data? int pageNumber = 2; int pageSize = 2; var page = employees .OrderBy(e => e.Id) .Skip((pageNumber - 1) * pageSize) .Take(pageSize); Explanation: Retrieve specific pages from data sets (…
var maxSalaryPerDept = employees What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainability, security, cost) When you would and would not use it in production Real-…
Answer: How to find max salary per department? var maxSalaryPerDept = employees .GroupBy(e => e.Department) .Select(g => new { Department = g.Key, MaxSalary = g.Max(e => e.Salary) }); What interviewe…
.SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainability, security, cost) When you…
Answer: How to check sequence equality ignoring order? bool areEqual = employees.Select(e => e.Id).OrderBy(id => id) .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); What inter…
var distinctByDeptAndSalary = employees .Select(g => g.First()); What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainability, security, cost) When you would a…
Answer: How to get distinct by multiple properties? var distinctByDeptAndSalary = employees .GroupBy(e => new { e.Department, e.Salary }) .Select(g => g.First()); What interviewers expect A clear definition…
Answer: int pageNumber = 1; int pageSize = 3; var totalCount = employees.Count(); var pageData = employees What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainabilit…
How to implement pagination with total count using LINQ? int pageNumber = 1; Follow : int pageSize = 3; var totalCount = employees.Count(); var pageData = employees .OrderBy(e => e.Id) .Skip((pageNumber - 1) * pageSiz…
var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainability, security, cost) When you would and would…
How to check if two sequences have the same elements regardless of order and duplicates? var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; bool areEqual = !list1.Except(list2).Any() && !list2.Except…
var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (performance, maintainability, security, cost) When you…
How to create a dictionary from a list with duplicate keys? var dict = employees .GroupBy(e => e.Department) .ToDictionary(g => g.Key, g => g.ToList()); Follow : foreach (var kvp in dict) Console.WriteLine($"{kv…
Answer: var list1 = new[] { "Alice", "Bob", "Charlie" }; var list2 = new[] { "Bob", "David", "Eva" }; var union = list1.Union(list2); What interviewers expect A clear definition tied to LINQ in LINQ projects Trade-offs (…
LINQ LINQ Tutorial · LINQ
var distinctByDept = employees .Select(g => g.First());
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to filter distinct objects by a property?
var distinctByDept = employees
.GroupBy(e => e.Department)
.Select(g => g.First());
Explanation:
Groups employees by department and selects one employee from each group to get distinct
departments.
LINQ LINQ Tutorial · LINQ
Answer: var salaries = employees.Select(e => e.Salary).ToList(); double runningTotal = 0; var runningTotals = salaries.Select(s => runningTotal += s);
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to calculate running totals using LINQ?
var salaries = employees.Select(e => e.Salary).ToList();
double runningTotal = 0;
var runningTotals = salaries.Select(s => runningTotal += s);
foreach (var total in runningTotals)
Console.WriteLine(total);
Explanation:
Accumulates sums as you iterate through the sequence.
LINQ LINQ Tutorial · LINQ
Answer: string searchName = "Alice"; var query = employees.AsQueryable(); query = query.Where(e => e.Name.Contains(searchName)); var result = query.ToList();
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to perform conditional LINQ queries?
string searchName = "Alice";
var query = employees.AsQueryable();
if (!string.IsNullOrEmpty(searchName))
query = query.Where(e => e.Name.Contains(searchName));
var result = query.ToList();
Follow :
Explanation:
Build LINQ queries dynamically based on conditions.
LINQ LINQ Tutorial · LINQ
Answer: var departmentsWithEmployees = new[] var allEmployees = departmentsWithEmployees .SelectMany(d => d.Employees);
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to flatten hierarchical data with SelectMany?
var departmentsWithEmployees = new[]
new { Department = "IT", Employees = new [] {"Bob", "Charlie"}
new { Department = "HR", Employees = new [] {"Alice", "Eva"} }
var allEmployees = departmentsWithEmployees
.SelectMany(d => d.Employees);
foreach (var emp in allEmployees)
Console.WriteLine(emp);
Explanation:
SelectMany flattens nested collections into a single sequence.
LINQ LINQ Tutorial · LINQ
var groupJoin = from d in departments into empGroup
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to group join with multiple collections?
var groupJoin = from d in departments
join e in employees on d.Name equals e.Department
into empGroup
select new { Department = d.Name, Employees =
empGroup };
foreach (var group in groupJoin)
Console.WriteLine($"{group.Department}:");
foreach (var emp in group.Employees)
Console.WriteLine($" - {emp.Name}");
Follow :
Explanation:
Groups employees under their respective departments.
LINQ LINQ Tutorial · LINQ
int pageNumber = 2; int pageSize = 2; var page = employees
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to use LINQ for paging data?
int pageNumber = 2;
int pageSize = 2;
var page = employees
.OrderBy(e => e.Id)
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize);
Explanation:
Retrieve specific pages from data sets (useful for UI pagination).
LINQ LINQ Tutorial · LINQ
var maxSalaryPerDept = employees
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
Answer: How to find max salary per department? var maxSalaryPerDept = employees .GroupBy(e => e.Department) .Select(g => new { Department = g.Key, MaxSalary = g.Max(e => e.Salary) });
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
.SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id));
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
Answer: How to check sequence equality ignoring order? bool areEqual = employees.Select(e => e.Id).OrderBy(id => id) .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id));
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
var distinctByDeptAndSalary = employees .Select(g => g.First());
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
Answer: How to get distinct by multiple properties? var distinctByDeptAndSalary = employees .GroupBy(e => new { e.Department, e.Salary }) .Select(g => g.First());
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
Answer: int pageNumber = 1; int pageSize = 3; var totalCount = employees.Count(); var pageData = employees
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to implement pagination with total count using LINQ?
int pageNumber = 1;
Follow :
int pageSize = 3;
var totalCount = employees.Count();
var pageData = employees
.OrderBy(e => e.Id)
.Skip((pageNumber - 1) * pageSize)
.Take(pageSize)
.ToList();
Console.WriteLine($"Total Employees: {totalCount}");
foreach(var emp in pageData)
Console.WriteLine($"{emp.Name} - {emp.Department}");
Explanation:
You get total count separately and then take the required page using Skip and Take.
LINQ LINQ Tutorial · LINQ
var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1};
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to check if two sequences have the same elements
regardless of order and duplicates?
var list1 = new[] {1, 2, 3, 4};
var list2 = new[] {4, 3, 2, 1};
bool areEqual = !list1.Except(list2).Any() &&
!list2.Except(list1).Any();
Console.WriteLine(areEqual); // Output: True
Explanation:
This checks if both lists contain the same elements, ignoring order and duplicates.
LINQ LINQ Tutorial · LINQ
var dict = employees .ToDictionary(g => g.Key, g => g.ToList());
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
LINQ LINQ Tutorial · LINQ
How to create a dictionary from a list with duplicate keys?
var dict = employees
.GroupBy(e => e.Department)
.ToDictionary(g => g.Key, g => g.ToList());
Follow :
foreach (var kvp in dict)
Console.WriteLine($"{kvp.Key} Department:");
foreach (var emp in kvp.Value)
Console.WriteLine($" - {emp.Name}");
Explanation:
Group employees by department and convert groups to dictionary entries.
LINQ LINQ Tutorial · LINQ
Answer: var list1 = new[] { "Alice", "Bob", "Charlie" }; var list2 = new[] { "Bob", "David", "Eva" }; var union = list1.Union(list2);
In a production LINQ application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.