P
prepair.app
Start interview →
EnglishУкраїнськаРусскийDeutsch
🟣

Middle .NET Backend Developer.NET interview questions

Middle · 2–4 years of experience

.NET interviews move between C# the language and the runtime underneath it — the CLR, the GC, how async/await actually works — before landing on ASP.NET Core and Entity Framework Core, where most real-world questions live. Below are the questions asked most often, each with a model answer. Middle: deeper understanding, optimization, and real-world situations.

Try it — no account needed
Preparing your question…

Topics to prepare

C# types, LINQ and nullable reference types
Async/await and the Task-based model
CLR, JIT and garbage collection
ASP.NET Core: middleware and dependency injection
Entity Framework Core and query performance
Testing with xUnit/Moq, Docker and cloud deployment

5 Middle-level questions with answers

1

What actually happens when you `await` a `Task`?

Answer

The compiler rewrites the method into a state machine: code before the await runs synchronously, and if the task is not complete yet, the method hands control back to its caller and frees the thread instead of blocking it. The continuation resumes when the task completes, by default on the captured SynchronizationContext, which is why library code calls ConfigureAwait(false) to avoid deadlocks and unnecessary context switches.

2

What are GC generations, and how do they affect the `IDisposable` pattern?

Answer

The CLR promotes surviving objects from generation 0 to 1 to 2, collecting gen 0 cheaply and often, and gen 2 rarely but expensively. The GC only reclaims managed memory — unmanaged resources like file handles or database connections need explicit cleanup, which is what IDisposable and a finalizer as a safety net are for: Dispose() releases them deterministically, and the finalizer catches the case where a caller forgot to call it.

3

How does EF Core change tracking cause performance problems, and how do you avoid them?

Answer

By default every entity loaded through a DbContext is tracked — EF Core keeps a snapshot to detect what changed when SaveChanges() runs. For a read-only list that is pure overhead, so read paths should use .AsNoTracking(). The other classic cost is the N+1 problem — accessing a navigation property inside a loop without Include() fires one query per row.

4

When would you choose Minimal APIs over MVC controllers in ASP.NET Core?

Answer

Minimal APIs skip the controller ceremony — a single app.MapGet(...) lambda with parameters bound from the route, query or body — which is enough for a small service and starts faster with less reflection overhead. Controllers earn their weight back once you need model-binding conventions, [ApiController] validation, filters, or a large surface area where grouping actions by resource keeps the codebase navigable.

5

How do you unit test a class that depends on other services in .NET?

Answer

xUnit is the default framework — [Fact] for a single case, [Theory] with [InlineData] for parameterized ones. Dependencies get replaced with Moq: Mock<IRepository> lets you set up return values with .Setup() and verify calls with .Verify(), so the test exercises the class in isolation instead of a real database. Over-mocking is the trap — a test that just checks five collaborators were called in order is testing the mock setup, not the behavior.

🦎

Reading answers is not enough

In a real interview you speak under pressure. Cam asks these same questions, scores every answer, and shows exactly what to fix.

Practice a Middle .NET Backend Developer interview →
Free · 3 interviews per month

Other levels — .NET Backend Developer

Junior .NET Backend DeveloperSenior .NET Backend DeveloperAll .NET Backend Developer questions

Other specializations

🔍Middle Manual QA🤖Middle QA AutomationMiddle Java Backend🐍Middle Python Backend🐘Middle PHP Backend🦫Middle Go Backend🟢Middle Node.js Backend💎Middle Ruby on Rails🔷Middle C++🟨Middle JavaScript