.NET Interview Questions for 3–5 Years Experience
A cross-technology set pitched at mid-level .NET developers — deeper C# and CLR, the ASP.NET Core pipeline and DI lifetimes, EF Core internals, SQL tuning and scenario questions.
By 3–5 years, interviewers expect you to explain mechanisms, not just name them: how the GC decides what to collect, why a captive dependency happens, why a query is slow and how you would prove it. This collection combines the mid-level questions from every technology.
C# & runtime depth
4 questionsIEnumerable<T> represents an in-memory sequence; LINQ operators run as compiled delegates and iterate objects client-side. IQueryable<T> represents a query against a remote provider (e.g. a database); LINQ…
Read detailed answerasync/await let you write non-blocking asynchronous code that reads sequentially. await on an incomplete Task returns control to the caller and registers a continuation; when the awaited operation finishes,…
Read detailed answerBoxing is wrapping a value type in an object (or interface) reference so it can live on the heap — it happens implicitly when you assign an int to an object. Unboxing is the explicit cast back to the value…
Read detailed answerThe .NET GC is a generational, mark-and-compact collector. New objects go in Gen 0; objects that survive a collection are promoted to Gen 1, then Gen 2. Most collections are small, fast Gen 0 sweeps. The GC…
Read detailed answerASP.NET Core depth
5 questionsA request enters through Kestrel, is handed to the middleware pipeline as an HttpContext, and passes through each middleware in registration order — exception handling, HTTPS redirection, static files,…
Read detailed answerA service lifetime controls how long the container keeps and reuses an instance. There are three: Transient — a new instance every time it is requested; Scoped — one instance per request (per DI scope);…
Read detailed answerTransient: new instance on every injection — most short-lived. Scoped: one instance per request, shared within that request. Singleton: one instance for the app's entire lifetime, shared by every request and…
Read detailed answerDbContext is registered as Scoped because it is a lightweight, stateful, not thread-safe unit-of-work. One instance per request lets every repository and service in that request share the same change tracker…
Read detailed answerA captive dependency is when a longer-lived service holds a reference to a shorter-lived one, “capturing” it and keeping it alive far longer than intended. The classic case is a Singleton that injects a…
Read detailed answerData depth
5 questionsEager loading pulls related data in the same query using Include(). Lazy loading fetches a navigation property automatically the first time you access it — convenient but the classic cause of the N+1 query…
Read detailed answerChange tracking is how EF Core knows what to save. When you query with tracking (the default), the context keeps a snapshot of each entity and assigns it a state — Unchanged, Added, Modified, Deleted. On…
Read detailed answerAn execution plan is the set of physical operations the query optimiser chose to run a query — which indexes to use, in what order to join tables, whether to seek or scan, how to sort and aggregate. The…
Read detailed answerMeasure first: capture the actual execution plan and STATISTICS IO/TIME. Then look for the usual culprits — a scan where a seek should happen (missing or unusable index), non-sargable predicates (functions on…
Read detailed answerYes. Every non-clustered index is extra data that must be updated on every INSERT, UPDATE (of an indexed column) and DELETE, so too many indexes slow writes and increase locking, logging and storage. Indexes…
Read detailed answerScenarios
3 questionsReproduce with realistic concurrency, then use data — server metrics (CPU, memory, GC, thread-pool queue), request tracing/APM, and the database's own view (slow query log, wait stats). The usual causes:…
Read detailed answerGet the exact stack trace and a correlation ID from structured logging, and identify the line and the reference that's null. “Intermittent” and “only in production” usually points to concurrency (a…
Read detailed answerSomething between the write and that user's read is serving an older version: an application or output cache that wasn't invalidated, a long-lived DbContext returning tracked (pre-update) entities, HTTP/CDN…
Read detailed answer