Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4608 total questions 4508 technical 100 career & HR 4272 from PDF library

Showing 2701–2725 of 4608

Career & HR topics

By tech stack

Popular tracks

Mid PDF
How to group join with multiple collections?

Short answer: How to group join with multiple collections? Explain a bit more var groupJoin = from d in departments join e in employees on d.Name equals e.Department into empGroup select new { Department = d.Name, Employ…

Mid PDF
How to use LINQ for paging data?

Short answer: int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageS…

Mid PDF
How to use LINQ for paging data?

Short answer: 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 fr…

Mid PDF
How to find max salary per department?

Short answer: var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxS…

Mid PDF
How to find max salary per department?

Short 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) }); How to find max salar…

Mid PDF
How to check sequence equality ignoring order?

Short answer: .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id =>…

Mid PDF
How to check sequence equality ignoring order?

Short answer: How to check sequence equality ignoring order? Explain a bit more bool areEqual = employees.Select(e => e.Id).OrderBy(id => id) .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); H…

Mid PDF
How to get distinct by multiple properties?

Short answer: var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); va…

Mid PDF
How to get distinct by multiple properties?

Short answer: How to get distinct by multiple properties? Explain a bit more var distinctByDeptAndSalary = employees .GroupBy(e => new { e.Department, e.Salary }) .Select(g => g.First()); How to get distinct by mul…

Mid PDF
How to implement pagination with total count using LINQ?

Short answer: .OrderBy(e => e.Id) .Skip((pageNumber - 1) * pageSize) .Take(pageSize) .ToList(); Console.WriteLine($"Total Employees: {totalCount}"); foreach(var emp in pageData) Console.WriteLine($"{emp…

Mid PDF
How to implement pagination with total count using LINQ?

Short answer: How to implement pagination with total count using LINQ? Explain a bit more int pageNumber = 1; Follow : int pageSize = 3; var totalCount = employees.Count(); var pageData = employees .OrderBy(e => e.Id)…

Mid PDF
How to check if two sequences have the same elements regardless of order and duplicates?

Short answer: var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = ne…

Mid PDF
How to check if two sequences have the same elements?

Short answer: 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() &&…

Mid PDF
How to create a dictionary from a list with duplicate keys?

Short answer: var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToLi…

Mid PDF
How to create a dictionary from a list with duplicate keys?

Short answer: 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.W…

Mid PDF
How to perform union of two collections without duplicates?

Short answer: foreach (var name in union) Console.WriteLine(name); Explanation: Union returns distinct elements from both collections. var list1 = new[] { "Alice", "Bob", "Charlie" }; var li…

Mid PDF
How to perform union of two collections without duplicates?

Short answer: How to perform union of two collections without duplicates? var list1 = new[] { "Alice", "Bob", "Charlie" }; var list2 = new[] { "Bob", "David", "Eva&q…

Mid PDF
How to perform intersection of two collections?

Short answer: var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var in…

Mid PDF
How to perform intersection of two collections?

Short answer: How to perform intersection of two collections? Explain a bit more var intersect = list1.Intersect(list2); foreach (var name in intersect) Console.WriteLine(name); // Output: Bob How to perform intersection…

Mid PDF
How to find elements present in the first but not in the second list?

Short answer: var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); va…

Mid PDF
How to find elements present in the first but not in the second?

Short answer: How to find elements present in the first but not in the second list? var except = list1.Except(list2); foreach (var name in except) Follow : Console.WriteLine(name); // Output: Alice, Charlie How to find e…

Mid PDF
How to find employees with salary between a range?

Short answer: ; foreach(var emp in midRange) Console.WriteLine($"{emp.Name} - {emp.Salary}"); var midRange = employees.Where(e => e.Salary >= 65000 && e.Salary <=. Example code 85000); foreach(…

Mid PDF
How to find employees with salary between a range?

Short answer: How to find employees with salary between a range? var midRange = employees.Where(e => e.Salary >= 65000 && e.Salary <= 85000); foreach(var emp in midRange) Console.WriteLine($&quot…

Mid PDF
How to group and order groups by count descending?

Short answer: var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var grou…

Mid PDF
How to group and order groups by count descending?

Short answer: How to group and order groups by count descending? var groupOrder = employees .GroupBy(e => e.Department) .OrderByDescending(g => g.Count()); foreach (var group in groupOrder) Console.WriteLine($&quot…

LINQ LINQ Tutorial · LINQ

Short answer: How to group join with multiple collections?

Explain a bit more

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.

Real-world example (ShopNest)

A sales report joins orders and customers, then GroupBy(c => c.City) to show revenue per city.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int…

Explain a bit more

pageNumber = 2; int pageSize = 2; var page = employees

Example code

int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees int pageNumber = 2; int pageSize = 2; var page = employees

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: 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). 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);…

Explain a bit more

Explanation: Retrieve specific pages from data sets (useful for UI pagination).

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees

Example code

var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees var maxSalaryPerDept = employees

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short 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) }); 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) }); How to… find max salary per department? var maxSalaryPerDept =…

Explain a bit more

employees .GroupBy(e => e.Department) .Select(g => new { Department = g.Key, MaxSalary = g.Max(e => e.Salary) }); 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) });

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id));

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: How to check sequence equality ignoring order?

Explain a bit more

bool areEqual = employees.Select(e => e.Id).OrderBy(id => id) .SequenceEqual(anotherList.Select(e => e.Id).OrderBy(id => id)); 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)); 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)); 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));

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary =…

Explain a bit more

employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First());

Example code

var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First()); var distinctByDeptAndSalary = employees .Select(g => g.First());

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: How to get distinct by multiple properties?

Explain a bit more

var distinctByDeptAndSalary = employees .GroupBy(e => new { e.Department, e.Salary }) .Select(g => g.First()); How to get distinct by multiple properties? var distinctByDeptAndSalary = employees .GroupBy(e => new { e.Department, e.Salary }) .Select(g => g.First()); How to get distinct by multiple properties? var distinctByDeptAndSalary = employees .GroupBy(e => new { e.Department, e.Salary }) .Select(g => g.First()); How to get distinct by multiple properties? var distinctByDeptAndSalary = employees .GroupBy(e => new { e.Department, e.Salary }) .Select(g => g.First());

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: .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. int pageNumber = 1;

Example code

int pageSize = 3;
var totalCount = employees.Count();
var pageData = employees

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: How to implement pagination with total count using LINQ?

Explain a bit more

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.

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var…

Explain a bit more

list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1};

Example code

var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1}; var list1 = new[] {1, 2, 3, 4}; var list2 = new[] {4, 3, 2, 1};

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: 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.

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees…

Explain a bit more

ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList());

Example code

var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList()); var dict = employees .ToDictionary(g => g.Key, g => g.ToList());

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: 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.

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: foreach (var name in union) Console.WriteLine(name); Explanation: Union returns distinct elements from both collections. var list1 = new[] { "Alice", "Bob", "Charlie" }; var list2 = new[] { "Bob", "David", "Eva" }; var union = list1.Union(list2);

Example code

foreach (var name in union) Console.WriteLine(name); Explanation: Union returns distinct elements from both collections. var list1 = new[] { "Alice", "Bob", "Charlie" };
var list2 = new[] { "Bob", "David", "Eva" };
var union = list1.Union(list2);

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: How to perform union of two collections without duplicates? var list1 = new[] { "Alice", "Bob", "Charlie" }; var list2 = new[] { "Bob", "David", "Eva" }; var union = list1.Union(list2); foreach (var name in union) Console.WriteLine(name); Explanation: Union returns distinct elements from both collections.

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2);

Example code

var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2); var intersect = list1.Intersect(list2);

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: How to perform intersection of two collections?

Explain a bit more

var intersect = list1.Intersect(list2); foreach (var name in intersect) Console.WriteLine(name); // Output: Bob How to perform intersection of two collections? var intersect = list1.Intersect(list2); foreach (var name in intersect) Console.WriteLine(name); // Output: Bob How to perform intersection of two collections? var intersect = list1.Intersect(list2); foreach (var name in intersect) Console.WriteLine(name); // Output: Bob How to perform intersection of two collections? var intersect = list1.Intersect(list2); foreach (var name in intersect) Console.WriteLine(name); // Output: Bob

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2);

Example code

var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2); var except = list1.Except(list2);

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: How to find elements present in the first but not in the second list? var except = list1.Except(list2); foreach (var name in except) Follow : Console.WriteLine(name); // Output: Alice, Charlie How to find elements present in the first but not in the second list?

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: ; foreach(var emp in midRange) Console.WriteLine($"{emp.Name} - {emp.Salary}"); var midRange = employees.Where(e => e.Salary >= 65000 && e.Salary <=.

Example code

85000); foreach(var emp in midRange) Console.WriteLine($"{emp.Name} - {emp.Salary}"); var midRange = employees.Where(e => e.Salary >= 65000 && e.Salary <=

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: How to find employees with salary between a range? var midRange = employees.Where(e => e.Salary >= 65000 &amp;&amp; e.Salary <= 85000); foreach(var emp in midRange) Console.WriteLine($"{emp.Name} - {emp.Salary}"); How to find employees with salary between a range?

Real-world example (ShopNest)

ShopNest uses LINQ to query orders: filter by date, project to a summary DTO, and order by total—readable C# that becomes SQL under EF Core.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees…

Explain a bit more

OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count());

Example code

var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count()); var groupOrder = employees .OrderByDescending(g => g.Count());

Real-world example (ShopNest)

A sales report joins orders and customers, then GroupBy(c => c.City) to show revenue per city.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

LINQ LINQ Tutorial · LINQ

Short answer: How to group and order groups by count descending? var groupOrder = employees .GroupBy(e => e.Department) .OrderByDescending(g => g.Count()); foreach (var group in groupOrder) Console.WriteLine($"{group.Key} has {group.Count()} employees"); How to group and order groups by count descending?

Real-world example (ShopNest)

A sales report joins orders and customers, then GroupBy(c => c.City) to show revenue per city.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details