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 2601–2625 of 4608

Career & HR topics

By tech stack

Popular tracks

Mid PDF
Repeat a value 5 times?

Short answer: var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fi…

Mid PDF
What does DefaultIfEmpty() do?

Short answer: What does DefaultIfEmpty() do? Returns a default value if the sequence is empty (e.g. in left join). Say this in the interview Define — one clear sentence (the short answer above). Example — relate it to a…

Mid PDF
How to write a subquery?

Short answer: var topEarners = employees .Where(e => e.Salary > employees.Average(x => x.Salary)); Example code var topEarners = employees .Where(e => e.Salary > employees.Average(x => x.Salary)); Real-…

Mid PDF
Check if a department has more than 2 employees?

Short answer: .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT&q…

Mid PDF
Check if a department has more than 2 employees?

Short answer: Check if a department has more than 2 employees? Explain a bit more bool deptCheck = employees .Count(e => e.Department == "IT") > 2; Check if a department has more than 2 employees? bool de…

Mid PDF
Create dictionary from list?

Short answer: var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id)…

Mid PDF
Sum salary by department, only if salary > 70k .Where(e => e.Salary > 70000) .GroupBy(e => e.Department)?

Short answer: var sum = employees .Select(g => new { g.Key, Sum = g.Sum(e => e.Salary) }); Example code var sum = employees .Select(g => new { g.Key, Sum = g.Sum(e => e.Salary) }); Real-world example (ShopNes…

Mid PDF
Sum salary by department, only if salary > 70k?

Short answer: Sum salary by department, only if salary > 70k Follow : var sum = employees .Where(e => e.Salary > 70000) .GroupBy(e => e.Department) .Select(g => new { g.Key, Sum = g.Sum(e => e.Salary) }…

Mid PDF
Find duplicate names .GroupBy(e => e.Name) .Where(g => g.Count() > 1)?

Short answer: var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNam…

Mid PDF
Find duplicate names?

Short answer: Find duplicate names var dupNames = employees .GroupBy(e => e.Name) .Where(g => g.Count() > 1) .Select(g => g.Key); Find duplicate names var dupNames = employees .GroupBy(e => e.Name) .Where(…

Mid PDF
Merge two employee lists?

Short answer: var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merg…

Mid PDF
Select only employees with even ID?

Short answer: var evens = employees.Where(e => e.Id % 2 == 0); var evens = employees.Where(e => e.Id % 2 == 0); var evens = employees.Where(e => e.Id % 2 == 0); var evens = employees.Where(e => e.Id % 2 == 0)…

Mid PDF
Group employees by first letter of name?

Short answer: var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e…

Mid PDF
Reverse the order?

Short answer: var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.R…

Mid PDF
Print all names in single comma-separated string?

Short answer: string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", empl…

Mid PDF
Safely get the first employee or null?

Short answer: var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var fi…

Mid PDF
How to handle exceptions in LINQ?

Short answer: var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.Fir…

Mid PDF
How to handle exceptions in LINQ?

Short answer: How to handle exceptions in LINQ? Use try-catch around enumeration, not the query: try { var result = employees.First(e => e.Salary > 999999); } catch (Exception ex) { Console.WriteLine("No match…

Mid PDF
What's the difference between Select() and SelectMany()?

Short answer: What's the difference between Select() and SelectMany()? Select() returns collection of collections. SelectMany() flattens them. Real-world example (ShopNest) ShopNest maps entities to DTOs with .Select(o =…

Mid PDF
Chaining multiple Where() calls .Where(e => e.Salary > 70000)?

Short answer: var result = employees .Where(e => e.Department == "IT"); var result = employees .Where(e => e.Department == "IT"); var result = employees .Where(e => e.Department == "IT&q…

Mid PDF
Chaining multiple Where() calls?

Short answer: Chaining multiple Where() calls var result = employees .Where(e => e.Salary > 70000) .Where(e => e.Department == "IT"); Chaining multiple Where() calls var result = employees .Where(e =&g…

Mid PDF
Find longest employee name?

Short answer: Find longest employee name var longest = employees .OrderByDescending(e => e.Name.Length) .FirstOrDefault(); Find longest employee name var longest = employees .OrderByDescending(e => e.Name.Length) .…

Mid PDF
Case-insensitive filtering?

Short answer: Case-insensitive filtering var hr = employees .Where(e => e.Department.Equals("hr", StringComparison.OrdinalIgnoreCase)); Case-insensitive filtering var hr = employees .Where(e => e.Departme…

Mid PDF
Select employee with second-highest salary?

Short answer: Select employee with second-highest salary var secondHighest = employees .OrderByDescending(e => e.Salary) .Skip(1) .FirstOrDefault(); ✅ Skips the top salary and selects the next one. Explain a bit more…

Mid PDF
Find employee with longest name?

Short answer: Find employee with longest name var longestName = employees .OrderByDescending(e => e.Name.Length) .FirstOrDefault(); Find employee with longest name var longestName = employees .OrderByDescending(e =&gt…

LINQ LINQ Tutorial · LINQ

Short answer: var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5);

Example code

var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5); var fives = Enumerable.Repeat("Hi", 5);

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: What does DefaultIfEmpty() do? Returns a default value if the sequence is empty (e.g. in left join).

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 topEarners = employees .Where(e => e.Salary > employees.Average(x => x.Salary));

Example code

var topEarners = employees
.Where(e => e.Salary > employees.Average(x => x.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: .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2; .Count(e => e.Department == "IT") > 2;

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: Check if a department has more than 2 employees?

Explain a bit more

bool deptCheck = employees .Count(e => e.Department == "IT") > 2; Check if a department has more than 2 employees? bool deptCheck = employees .Count(e => e.Department == "IT") > 2; Check if a department has more than 2 employees? bool deptCheck = employees .Count(e => e.Department == "IT") > 2; Check if a department has more than 2 employees? bool deptCheck = employees .Count(e => e.Department == "IT") > 2;

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 empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id);

Example code

var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.Id); var empDict = employees.ToDictionary(e => e.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 sum = employees .Select(g => new { g.Key, Sum = g.Sum(e => e.Salary) });

Example code

var sum = employees
.Select(g => new { g.Key, Sum = g.Sum(e => e.Salary) });

Real-world example (ShopNest)

ShopNest filters active products with products.Where(p => p.IsActive && p.Stock > 0) before showing the catalog.

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: Sum salary by department, only if salary > 70k Follow : var sum = employees .Where(e => e.Salary > 70000) .GroupBy(e => e.Department) .Select(g => new { g.Key, Sum = g.Sum(e => e.Salary) }); Sum salary by department, only if salary > 70k Follow : var sum = employees .Where(e => e.Salary > 70000) .GroupBy(e => e.Department)… Select(g => new { g.Key, Sum =…… Sum salary by department, only if salary > 70k Follow : var…

Explain a bit more

sum = employees .Where(e => e.Salary > 70000) .GroupBy(e => e.Department) .Select(g => new { g.Key, Sum = g.Sum(e => e.Salary) }); Sum salary by department, only if salary > 70k Follow : var sum = employees .Where(e => e.Salary > 70000) .GroupBy(e => e.Department)… Select(g => new { g.Key, Sum = g.Sum(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: var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key);

Example code

var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key); var dupNames = employees .Select(g => g.Key);

Real-world example (ShopNest)

ShopNest filters active products with products.Where(p => p.IsActive && p.Stock > 0) before showing the catalog.

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: Find duplicate names var dupNames = employees .GroupBy(e => e.Name) .Where(g => g.Count() > 1) .Select(g => g.Key); Find duplicate names var dupNames = employees .GroupBy(e => e.Name) .Where(g => g.Count() > 1) .Select(g => g.Key); Find duplicate names var dupNames = employees .GroupBy(e => e.Name) .Where(g => g.Count() > 1) .Select(g => g.Key); Find… duplicate names var dupNames = employees .GroupBy(e => e.Name)…

Explain a bit more

Where(g => g.Count() > 1) .Select(g => g.Key);

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 merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2);

Example code

var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = list1.Union(list2); var merged = 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: var evens = employees.Where(e => e.Id % 2 == 0); var evens = employees.Where(e => e.Id % 2 == 0); var evens = employees.Where(e => e.Id % 2 == 0); var evens = employees.Where(e => e.Id % 2 == 0);

Real-world example (ShopNest)

ShopNest maps entities to DTOs with .Select(o => new OrderSummaryDto { Id = o.Id, Total = o.Total }) so the API does not leak internal fields.

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 alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e =>…

Example code

var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]); var alphaGroup = employees .GroupBy(e => e.Name[0]);

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: var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse();

Example code

var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse(); var reversed = employees.Reverse();

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: string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result =…

Explain a bit more

string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name));

Example code

string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name)); string result = string.Join(", ", employees.Select(e => e.Name));

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 first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault();

Example code

var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault(); var first = employees.FirstOrDefault();

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 result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e =>…

Example code

var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999); var result = employees.First(e => e.Salary > 999999);

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 handle exceptions in LINQ? Use try-catch around enumeration, not the query: try { var result = employees.First(e => e.Salary > 999999); } catch (Exception ex) { Console.WriteLine("No match found."); How to handle exceptions in LINQ? How to handle exceptions in LINQ? Use try-catch around enumeration, not the query: try { var result =… employees.First(e… => e.Salary > 999999); } catch (Exception ex) {…

Explain a bit more

Console.WriteLine("No match found."); How to handle exceptions in LINQ?

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: What's the difference between Select() and SelectMany()? Select() returns collection of collections. SelectMany() flattens them.

Real-world example (ShopNest)

ShopNest maps entities to DTOs with .Select(o => new OrderSummaryDto { Id = o.Id, Total = o.Total }) so the API does not leak internal fields.

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 result = employees .Where(e => e.Department == "IT"); var result = employees .Where(e => e.Department == "IT"); var result = employees .Where(e => e.Department == "IT"); var result = employees .Where(e => e.Department == "IT");

Real-world example (ShopNest)

ShopNest filters active products with products.Where(p => p.IsActive && p.Stock > 0) before showing the catalog.

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: Chaining multiple Where() calls var result = employees .Where(e => e.Salary > 70000) .Where(e => e.Department == "IT"); Chaining multiple Where() calls var result = employees .Where(e => e.Salary > 70000) .Where(e => e.Department == "IT"); Chaining multiple Where() calls var result = employees .Where(e => e.Salary > 70000) .Where(e => e.Department == "IT");… Chaining multiple Where() calls var result = employees…

Explain a bit more

Where(e => e.Salary > 70000) .Where(e => e.Department == "IT");

Real-world example (ShopNest)

ShopNest filters active products with products.Where(p => p.IsActive && p.Stock > 0) before showing the catalog.

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: Find longest employee name var longest = employees .OrderByDescending(e => e.Name.Length) .FirstOrDefault(); Find longest employee name var longest = employees .OrderByDescending(e => e.Name.Length) .FirstOrDefault(); Find longest employee name var longest = employees .OrderByDescending(e => e.Name.Length) .FirstOrDefault(); Find longest employee name var… longest = employees .OrderByDescending(e => e.Name.Length)…

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: Case-insensitive filtering var hr = employees .Where(e => e.Department.Equals("hr", StringComparison.OrdinalIgnoreCase)); Case-insensitive filtering var hr = employees .Where(e => e.Department.Equals("hr", StringComparison.OrdinalIgnoreCase)); Case-insensitive filtering var hr = employees .Where(e => e.Department.Equals("hr",… StringComparison.OrdinalIgnoreCase)); Case-insensitive filtering var hr = employees…

Explain a bit more

Where(e => e.Department.Equals("hr", StringComparison.OrdinalIgnoreCase));

Real-world example (ShopNest)

ShopNest filters active products with products.Where(p => p.IsActive && p.Stock > 0) before showing the catalog.

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: Select employee with second-highest salary var secondHighest = employees .OrderByDescending(e => e.Salary) .Skip(1) .FirstOrDefault(); ✅ Skips the top salary and selects the next one.

Explain a bit more

Select employee with second-highest salary var secondHighest = employees .OrderByDescending(e => e.Salary) .Skip(1) .FirstOrDefault(); ✅ Skips the top salary and selects the next one. Select employee with second-highest salary var secondHighest = employees .OrderByDescending(e => e.Salary) .Skip(1) .FirstOrDefault(); ✅ Skips the top salary and selects the next one.

Real-world example (ShopNest)

ShopNest maps entities to DTOs with .Select(o => new OrderSummaryDto { Id = o.Id, Total = o.Total }) so the API does not leak internal fields.

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: Find employee with longest name var longestName = employees .OrderByDescending(e => e.Name.Length) .FirstOrDefault(); Find employee with longest name var longestName = employees .OrderByDescending(e => e.Name.Length) .FirstOrDefault(); Find employee with longest name var longestName = employees .OrderByDescending(e => e.Name.Length) .FirstOrDefault(); Find… employee with longest name var longestName = employees…

Explain a bit more

OrderByDescending(e => e.Name.Length) .FirstOrDefault();

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
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