0% found this document useful (0 votes)
15 views29 pages

C# .NET Interview Questions Guide

Uploaded by

arman.merchant26
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views29 pages

C# .NET Interview Questions Guide

Uploaded by

arman.merchant26
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C# / .

NET Questions
Created by Arman Merchant

Created time @September 3, 2025 8:54 PM

Tags

📘Guide
Complete .NET & SQL Interview Prep

🔹 C# / .NET Questions
Q1. Why use an Interface?
Defines a contract without implementation.

Promotes loose coupling.

Enables testability and mocking.

Q2. What is Loose Coupling?


Classes depend on abstractions (interfaces) instead of concrete classes.

Improves flexibility, testability, maintainability.

Example:

public interface INotifier { void Notify(string msg); }


public class EmailNotifier : INotifier {
public void Notify(string msg) => [Link]("Email: " + msg);
}
public class OrderService {
private readonly INotifier _notifier;
public OrderService(INotifier notifier) { _notifier = notifier; }
public void PlaceOrder() => _notifier.Notify("Order placed!");
}

C# / .NET Questions 1
Q3. What is Dependency Injection (DI)? Why use it?
Definition: Dependencies provided externally instead of created inside.

Benefits: Loose coupling, easier testing, centralized config, scalability.

Service Lifetimes in [Link] Core:


Transient

New instance created each time.

Example: IEmailSenderService .

Analogy: Coffee machine → new cup each order.

[Link]<IEmailSenderService, EmailSenderService>();

Scoped

One instance per HTTP request.

Example: DbContext .

Analogy: Rental car → used for the trip, then returned.

[Link]<MyDbContext>();

Singleton

One instance for entire app lifetime.

Example: ICacheService .

Analogy: House key → same key reused.

[Link]<ICacheService, MemoryCacheService>();

Q4. HttpClientFactory & AzureAdService Example


Problem with HttpClient

C# / .NET Questions 2
Creating per request → socket exhaustion.

Keeping alive forever → DNS changes ignored.

Solution → IHttpClientFactory

Usage

[Link]<GitHubService>(client =>
{
[Link] = new Uri("[Link]
});

AzureAdService Example

public class AzureAdService


{
private readonly HttpClient _httpClient;
private readonly IMemoryCache _cache;

public AzureAdService(HttpClient httpClient, IMemoryCache cache)


{
_httpClient = httpClient;
_cache = cache;
}

public async Task<string> GetTokenAsync()


{
if (_cache.TryGetValue("AccessToken", out string token))
return token;

var response = await _httpClient.PostAsync("[Link]


[Link]/.../token", new StringContent(...));
token = await [Link]();

_cache.Set("AccessToken", token, [Link](55));


return token;
}

C# / .NET Questions 3
}

Registration

[Link]<AzureAdService>(); // Typed client


[Link]();

Lifetime Choice

Singleton → best if token is cached globally (client-credentials flow).

Scoped → if token is per-request (user context).

Avoid Transient → too many new instances.

Q5. Middleware
Request pipeline
components: UseRouting , UseCors , UseAuthentication , UseAuthorization , UseSession .

Q6. Anti-Forgery Token


Prevents CSRF attacks by validating hidden + cookie token.

Q7. CORS
Cross-Origin Resource Sharing → allows/blocks requests across domains.

Q8. Passing Data Controller → View


ViewBag , ViewData , TempData , strongly typed models, Partial Views.

Q9. Decryption vs Hashing


Decryption: reversible.

Hashing: one-way.

Q10. Thread vs Async


Thread = OS execution unit.

C# / .NET Questions 4
Async = doesn’t create thread; frees thread during I/O.

Q11. Prevent multiple threads entering same code


Use: lock , Monitor , Mutex , SemaphoreSlim .

Q12. Delegate, Func, Action, Predicate


Delegate: function pointer.

Func<T>: returns value.

Action<T>: void.

Predicate<T>: returns bool.

Q13. EF Join Example

var q = from e in [Link]


join d in [Link] on [Link] equals [Link]
select new { [Link], [Link] };

Q14. REST & Stateless


REST = Representational State Transfer.

Stateless → each request carries needed data.

Q15. JWT Validation


Split → recompute signature → compare → validate claims.

Q16. ref vs out


ref: must be initialized; can read/write.

out: no initialization needed; must assign inside.

Q17. Parallel Programming


Run tasks concurrently ( [Link] , [Link] , PLINQ).

C# / .NET Questions 5
Q18. IEnumerable vs IQueryable (Deep Dive)
IEnumerable

Works in-memory.

Filters after fetching data.

IEnumerable<Employee> emps = [Link];


var result = [Link](e => [Link] > 50000); // client-side

IQueryable

Builds expression → SQL.

Filters before fetching.

IQueryable<Employee> emps = [Link];


var result = [Link](e => [Link] > 50000); // server-side

Analogy: IEnumerable = download Excel then filter. IQueryable = filter on


server then download.

Q19. AuthN vs AuthZ


AuthN: who you are.

AuthZ: what you can do.

Q20. JWT
Client sends token → server validates signature & claims.

Q21. Rate Limiting


Restricts requests/time.

Algorithms: Fixed window, Sliding window, Token bucket.

🔹 SQL Questions
C# / .NET Questions 6
Q1. Delete duplicates

WITH d AS (
SELECT *, ROW_NUMBER() OVER (PARTITION BY Col1, Col2 ORDER BY (S
ELECT 1)) rn
FROM MyTable
)
DELETE FROM d WHERE rn > 1;

Q2. Show “India” first

SELECT * FROM Country


ORDER BY CASE WHEN Name='India' THEN 0 ELSE 1 END, Name;

Q3. Second highest salary

SELECT MAX(Salary)
FROM Employee
WHERE Salary < (SELECT MAX(Salary) FROM Employee);

Q4. Highest salary per department

SELECT DeptId, MAX(Salary)


FROM Employee
GROUP BY DeptId;

Q5. Find duplicates

SELECT Col1, COUNT(*)


FROM MyTable
GROUP BY Col1

C# / .NET Questions 7
HAVING COUNT(*) > 1;

Q6. GROUP BY vs HAVING


GROUP BY = create groups.

HAVING = filter groups.

Q7. INNER JOIN

SELECT [Link], [Link]


FROM Employee e
INNER JOIN Department d ON [Link] = [Link];

Q8. ACID
Atomicity: all or none.

Consistency: rules preserved.

Isolation: no interference.

Durability: permanent commit.

Q9. Indexing
Purpose: faster lookups.

Downside: slows inserts/updates.

Q10. SQL Injection


Attack: malicious SQL in inputs.

Example:

SELECT * FROM Users WHERE Name = '" + userInput + "'";

If input = "admin' OR 1=1 --" , bypass login.

C# / .NET Questions 8
Prevention: Parameterized queries, stored procs, input validation, least
privilege.

Q11. SQL Optimization


Use indexes properly.

Avoid SELECT * .

Use joins instead of nested queries.

Analyze execution plans.

Normalize data; denormalize selectively.

Partition large tables.

Cache frequent results.

Q12. SQL Normalization


Process → reduce redundancy, improve integrity.

Forms

1NF → atomic values.

2NF → no partial dependency.

3NF → no transitive dependency.

Example

Orders(OrderId, CustomerName, Product1, Product2, Product3)

Normalized:

Customers(CustomerId, Name)
Orders(OrderId, CustomerId, OrderDate)
OrderItems(OrderItemId, OrderId, ProductId)

🔹 LINQ Questions
C# / .NET Questions 9
1️⃣ What is LINQ? → Query collections in C#.
2️⃣ Types → Objects, Entities, SQL, XML.
3️⃣ IEnumerable vs IQueryable → client vs server.
4️⃣ Deferred Execution → runs when enumerated.
5️⃣ Immediate Execution → , . ToList() Count()

6️⃣ Select vs SelectMany → one-to-one vs flatten.


7️⃣ Anonymous Types → .
new { Name="Arman" }

8️⃣ Lambda Expressions → . x => x+1

9️⃣ First(), FirstOrDefault(), Single(), SingleOrDefault().


🔟 Why LINQ over SQL? → strongly typed, IntelliSense, safer.
🔹 OOPs in C#
Encapsulation

class BankAccount {
private decimal balance;
public void Deposit(decimal amt) => balance += amt;
public decimal GetBalance() => balance;
}

Inheritance

class Animal { public void Eat(){} }


class Dog : Animal { public void Bark(){} }

Polymorphism

class Shape { public virtual void Draw(){} }


class Circle : Shape { public override void Draw(){} }

Abstraction

C# / .NET Questions 10
abstract class Vehicle { public abstract void Start(); }
class Car : Vehicle { public override void Start(){} }

🔹 SQL Analogies for OOP


Encapsulation → Views, Stored Procedures.

Inheritance → Parent-child tables.

Polymorphism → UNION queries, Views.

Abstraction → Functions, Views.

🔹 C# / .NET Questions
Q1. Why use an Interface?
Defines a contract without implementation.

Promotes loose coupling.

Enables testability and mocking.

Q2. What is Loose Coupling?


Classes depend on abstractions (interfaces) instead of concrete classes.

Improves flexibility, testability, maintainability.

Example:

public interface INotifier { void Notify(string msg); }


public class EmailNotifier : INotifier {
public void Notify(string msg) => [Link]("Email: " + msg);
}
public class OrderService {
private readonly INotifier _notifier;
public OrderService(INotifier notifier) { _notifier = notifier; }
public void PlaceOrder() => _notifier.Notify("Order placed!");

C# / .NET Questions 11
}

Q3. What is Dependency Injection (DI)? Why use it?


Definition: Dependencies provided externally instead of created inside.

Benefits: Loose coupling, easier testing, centralized config, scalability.

Service Lifetimes in [Link] Core:


Transient

New instance each time.

Example: IEmailSenderService .

Analogy: Coffee machine → new cup each order.

[Link]<IEmailSenderService, EmailSenderService>();

Scoped

One instance per HTTP request.

Example: DbContext .

Analogy: Rental car → used for the trip, then returned.

[Link]<MyDbContext>();

Singleton

One instance for entire app lifetime.

Example: ICacheService .

Analogy: House key → same key reused.

[Link]<ICacheService, MemoryCacheService>();

C# / .NET Questions 12
Q4. HttpClientFactory & AzureAdService Example
Problem with HttpClient

Creating per request → socket exhaustion.

Keeping alive forever → ignores DNS changes.

Solution → IHttpClientFactory

Typed Client Example

public class AzureAdService


{
private readonly HttpClient _httpClient;
private readonly IMemoryCache _cache;

public AzureAdService(HttpClient httpClient, IMemoryCache cache)


{
_httpClient = httpClient;
_cache = cache;
}

public async Task<string> GetTokenAsync()


{
if (_cache.TryGetValue("AccessToken", out string token))
return token;

var response = await _httpClient.PostAsync("[Link]


[Link]/.../token", new StringContent(...));
token = await [Link]();

_cache.Set("AccessToken", token, [Link](55));


return token;
}
}

Registration

C# / .NET Questions 13
[Link]<AzureAdService>(); // Typed client
[Link]();

Lifetime Choice

Singleton → best if token is cached globally (client-credentials flow).

Scoped → if token depends on per-request context (user flow).

Avoid Transient.

Q5. Middleware
Request pipeline
components: UseRouting , UseCors , UseAuthentication , UseAuthorization , UseSession .

Q6. Anti-Forgery Token


Prevents CSRF attacks.

Validates hidden + cookie token pair.

Q7. CORS
Cross-Origin Resource Sharing → allows/blocks requests across domains.

Q8. Passing Data Controller → View


ViewBag , ViewData , TempData , strongly typed models, Partial Views.

Q9. Decryption vs Hashing


Decryption: reversible with key.

Hashing: one-way, integrity check.

Q10. Thread vs Async


Thread = OS execution unit.

Async = doesn’t create thread; frees thread during I/O.

C# / .NET Questions 14
Q11. Prevent multiple threads entering same code
Use: lock , Monitor , Mutex , SemaphoreSlim .

Q12. Delegate, Func, Action, Predicate


Delegate: function pointer.

Func<T>: returns value.

Action<T>: void.

Predicate<T>: returns bool.

Q13. EF Join Example

var q = from e in [Link]


join d in [Link] on [Link] equals [Link]
select new { [Link], [Link] };

Q14. REST & Stateless


REST = Representational State Transfer.

Stateless → each request carries needed data.

Q15. JWT Validation


Split → recompute signature → compare → validate claims.

Q16. ref vs out


ref: must be initialized; can read/write.

int x = 5;
Update(ref x);

out: no initialization needed; must assign inside.

C# / .NET Questions 15
GetValues(out int a, out int b);

Q17. Parallel Programming


Run tasks concurrently ( [Link] , [Link] , PLINQ`).

Q18. IEnumerable vs IQueryable (Deep Dive)


IEnumerable

Works in-memory.

Filters after fetching data.

IEnumerable<Employee> emps = [Link];


var result = [Link](e => [Link] > 50000); // client-side

IQueryable

Builds expression → SQL.

Filters before fetching.

IQueryable<Employee> emps = [Link];


var result = [Link](e => [Link] > 50000); // server-side

Analogy: IEnumerable = download Excel then filter. IQueryable = filter on


server then download.

Q19. AuthN vs AuthZ


AuthN: who you are.

AuthZ: what you can do.

Q20. JWT
Client sends token → server validates signature & claims.

C# / .NET Questions 16
Q21. Rate Limiting
Restricts requests/time.

Algorithms: Fixed window, Sliding window, Token bucket.

🔹 SQL Questions
Q1. Delete duplicates

WITH d AS (
SELECT *, ROW_NUMBER() OVER (PARTITION BY Col1, Col2 ORDER BY (S
ELECT 1)) rn
FROM MyTable
)
DELETE FROM d WHERE rn > 1;

Q2. Show “India” first

SELECT * FROM Country


ORDER BY CASE WHEN Name='India' THEN 0 ELSE 1 END, Name;

Q3. Second highest salary

SELECT MAX(Salary)
FROM Employee
WHERE Salary < (SELECT MAX(Salary) FROM Employee);

Q4. Highest salary per department

SELECT DeptId, MAX(Salary)


FROM Employee

C# / .NET Questions 17
GROUP BY DeptId;

Q5. Find duplicates

SELECT Col1, COUNT(*)


FROM MyTable
GROUP BY Col1
HAVING COUNT(*) > 1;

Q6. GROUP BY vs HAVING


GROUP BY = create groups.

HAVING = filter groups.

Q7. INNER JOIN

SELECT [Link], [Link]


FROM Employee e
INNER JOIN Department d ON [Link] = [Link];

Q8. ACID
Atomicity: all or none.

Consistency: rules preserved.

Isolation: no interference.

Durability: permanent commit.

Q9. Indexing
Purpose: faster lookups.

Downside: slows inserts/updates.

C# / .NET Questions 18
Q10. SQL Injection (with Example & Prevention)
Vulnerable

string query = $"SELECT * FROM Users WHERE Username = '{user}' AND


Password = '{pass}'";

Attack

Input → admin' OR 1=1 --

Query → always true.


Prevention → Parameterized Query

string query = "SELECT * FROM Users WHERE Username=@u AND Passw


ord=@p";
var cmd = new SqlCommand(query, conn);
[Link]("@u", username);
[Link]("@p", password);

Stored Procedure

CREATE PROCEDURE GetUser @u NVARCHAR(50), @p NVARCHAR(50)


AS
SELECT * FROM Users WHERE Username=@u AND Password=@p;

Entity Framework

var user = [Link](u => [Link] == username && [Link]


sword == password);

✅ ORM and parameters ensure injection safety.


Q11. SQL Optimization
Use indexes wisely.

C# / .NET Questions 19
Avoid SELECT * .

Use joins instead of nested queries.

Analyze execution plans.

Normalize, denormalize selectively.

Partition large tables.

Cache frequent queries.

Q12. SQL Normalization


Process → reduce redundancy.

Forms

1NF → atomic values.

2NF → no partial dependency.

3NF → no transitive dependency.

Example
Unnormalized:

Orders(OrderId, CustomerName, Product1, Product2, Product3)

Normalized:

Customers(CustomerId, Name)
Orders(OrderId, CustomerId, OrderDate)
OrderItems(OrderItemId, OrderId, ProductId)

🔹 LINQ Questions
1️⃣ What is LINQ? → Query collections in C#.
2️⃣ Types → Objects, Entities, SQL, XML.
3️⃣ IEnumerable vs IQueryable → client vs server.
4️⃣ Deferred Execution → runs when enumerated.
C# / .NET Questions 20
5️⃣ Immediate Execution → , . ToList() Count()

6️⃣ Select vs SelectMany → one-to-one vs flatten.


7️⃣ Anonymous Types → .
new { Name="Arman" }

8️⃣ Lambda Expressions → . x => x+1

9️⃣ First(), FirstOrDefault(), Single(), SingleOrDefault().


🔟 Why LINQ over SQL? → strongly typed, IntelliSense, safer.
🔹 OOPs in C#
Encapsulation

class BankAccount {
private decimal balance;
public void Deposit(decimal amt) => balance += amt;
public decimal GetBalance() => balance;
}

Inheritance

class Animal { public void Eat(){} }


class Dog : Animal { public void Bark(){} }

Polymorphism

class Shape { public virtual void Draw(){} }


class Circle : Shape { public override void Draw(){} }

Abstraction

abstract class Vehicle { public abstract void Start(); }


class Car : Vehicle { public override void Start(){} }

C# / .NET Questions 21
🔹 SQL Analogies for OOP
Encapsulation → Views, Stored Procedures.

Inheritance → Parent-child tables.

Polymorphism → UNION queries, Views.

Abstraction → Functions, Views.

1) SQL Normalization — detailed, with


examples
Normalization = organizing tables to reduce repetition and avoid update bugs.
Think of it as cleaning a messy cupboard so every item has the right shelf, and
you don’t keep the same thing in five places.
We’ll start with a messy table and normalize it step by step.

Unnormalized (lots of repetition)

Orders
-----------------------------------------------------------------------
OrderId | CustomerName | CustomerAddress | Product1 | Product2
-----------------------------------------------------------------------
101 | Alice | 12 King St, Waterloo | Pen | Notebook
102 | Alice | 12 King St, Waterloo | Pencil | Notebook
103 | Bob | 88 Queen St, Kitchener | Pen | Ruler

Problems:

Customer info repeats on every order.

Multiple product columns ( Product1 , Product2 )—what if there are 3 or 10


products?

C# / .NET Questions 22
1NF (First Normal Form): make values atomic; no
repeating groups
One value per cell.

Put repeating products into rows, not columns.

Split orders and items:

Orders
---------------------------------
OrderId | CustomerName | Address
---------------------------------
101 | Alice | 12 King St, Waterloo
102 | Alice | 12 King St, Waterloo
103 | Bob | 88 Queen St, Kitchener

OrderItems
-----------------------------
OrderId | Product
-----------------------------
101 | Pen
101 | Notebook
102 | Pencil
102 | Notebook
103 | Pen
103 | Ruler

Better, but customer details still repeat for Alice.

2NF (Second Normal Form): remove partial


dependencies on a composite key
If a table’s primary key is (OrderId, Product), any column must depend on
the whole key—not just part of it.

Customer info depends on Order, not on (Order, Product). So move


customers and products to their own tables.

Create separate Customers and Products:

C# / .NET Questions 23
Customers
-------------------------------
CustomerId | Name | Address
-------------------------------
1 | Alice | 12 King St, Waterloo
2 | Bob | 88 Queen St, Kitchener

Orders
-------------------------
OrderId | CustomerId | OrderDate
-------------------------
101 | 1 | 2025-09-03
102 |1 | 2025-09-03
103 |2 | 2025-09-03

Products
------------------
ProductId | Name
------------------
10 | Pen
11 | Notebook
12 | Pencil
13 | Ruler

OrderItems
-----------------------------
OrderId | ProductId | Qty
-----------------------------
101 | 10 |1
101 | 11 |1
102 | 12 |1
102 | 11 |1
103 | 10 |1
103 | 13 |1

Now a product’s name lives once in Products , and each customer


lives once in Customers .

C# / .NET Questions 24
3NF (Third Normal Form): remove transitive
dependencies
Non-key columns shouldn’t depend on other non-key columns.

Example: if Customers had PostalCode and we also stored City that can be
derived from PostalCode , that’s a transitive dependency. Store the lookup in
one place (e.g., PostalCodes table) or compute it.

Rule of thumb: Every non-key column should depend only on the key, the
whole key, and nothing but the key.

Why normalize?
Consistency: update a product name once, everywhere it’s used is correct.

Space: don’t repeat the same strings a thousand times.

Speed: indexes on clean tables work better.

Fewer bugs: no conflicting copies of the same fact.

you’re five 😊
2) The WITH query (CTE) — explain like

Imagine you’re building a LEGO house. First you make a small base and give it
a name (“base”). Then you say: “Now, using that base, build the whole house.”
A Common Table Expression (CTE) is like naming your small base so you
can use it right away to build something bigger.

You write: WITH base AS (…mini-query…) SELECT … FROM base …

The part in WITH is your named mini-result.

Then you use that name in your main query—just like using your LEGO base
to build the house.

It helps you:

Break a big query into easy steps.

Reuse that step multiple times.

Write recursive queries (like family trees or org charts).

C# / .NET Questions 25
2a) Using WITH to find and delete
duplicates (classic interview favorite)
Goal: keep 1 row per “natural key” (e.g., Email ), delete the extras.

-- 1) Identify duplicates and rank each group


WITH ranked AS (
SELECT
Id,
Email,
ROW_NUMBER() OVER (PARTITION BY Email ORDER BY Id) AS rn
FROM [Link]
)
-- 2) Delete all but the first row per Email
DELETE FROM ranked
WHERE rn > 1;

How it works:

In the CTE ranked , we assign rn = 1, 2, 3… within each Email.

rn = 1 is the keeper; rn > 1 are duplicates.

We delete the extras.

Safety tip (always do this first):

WITH ranked AS (
SELECT Id, Email,
ROW_NUMBER() OVER (PARTITION BY Email ORDER BY Id) AS rn
FROM [Link]
)
SELECT * FROM ranked WHERE rn > 1; -- preview what you'd delete

Why CTE over subqueries?

Cleaner to read.

You can reuse the named step.

C# / .NET Questions 26
Works great with window functions like ROW_NUMBER() .

2b) Another handy WITH example (step-by-step


aggregation)
Find customers with total spend > $500:

WITH spend AS (
SELECT [Link], SUM([Link] * [Link]) AS TotalSpend
FROM Orders o
JOIN OrderItems oi ON [Link] = [Link]
JOIN Products p ON [Link] = [Link]
GROUP BY [Link]
)
SELECT [Link], [Link]
FROM spend s
JOIN Customers c ON [Link] = [Link]
WHERE [Link] > 500
ORDER BY [Link] DESC;

First, we build the “spend” LEGO base.

Then we select from it to get the final answer.

2c) Recursive WITH (bonus)


Useful for org charts or folder trees.

WITH Org AS (
SELECT EmployeeId, ManagerId, Name, 0 AS Level
FROM Employees
WHERE ManagerId IS NULL -- top boss

UNION ALL

SELECT [Link], [Link], [Link], [Link] + 1


FROM Employees e
JOIN Org o ON [Link] = [Link]

C# / .NET Questions 27
)
SELECT * FROM Org ORDER BY Level, Name;

The CTE calls itself to walk down the tree.

3) Duplicate strategies (alternatives)


Option A: CTE + ROW_NUMBER() (most common)
Shown above—best mix of clarity and control.

Option B: Keep the lowest Id per key with a self-join

DELETE u
FROM [Link] u
JOIN [Link] uKeep
ON [Link] = [Link]
AND [Link] > [Link]; -- delete higher Ids; keep the lowest

Be careful—this assumes the lowest Id is the one you want to keep.

Option C: Insert into a new clean table


When you’re nervous about deletes:

SELECT MIN(Id) AS Id, Email, MIN(OtherCol) AS OtherCol


INTO dbo.Users_Clean
FROM [Link]
GROUP BY Email;

Then swap tables (in a transaction), re-create constraints/indexes.

4) Quick checklist for duplicates


Pick your natural key (Email? [FirstName, LastName, DOB]?).

Preview rows to delete with a CTE SELECT first.

C# / .NET Questions 28
Wrap in a transaction if it’s production.

Create a unique index after cleanup to stop future duplicates:

CREATE UNIQUE INDEX UX_Users_Email ON [Link](Email);

TL;DR
Normalization = split big, repetitive tables into clean related tables (1NF →
2NF → 3NF) so each fact is stored once.

WITH / CTE = name a mini-result and then use it in the main query—great
for readability, window functions, recursive queries.

Delete duplicates = CTE + ROW_NUMBER() is your interview-ready go-to.

C# / .NET Questions 29

You might also like