Top 100 .NET Developer Interview Questions and Answers
The core .NET interview questions grouped by category — C#, OOP, the CLR, ASP.NET MVC, ASP.NET Core, Web API, Entity Framework, SQL Server and scenario questions — each with a real answer, not just a link.
This is Prismita's flagship collection: the questions that come up again and again in .NET developer interviews, grouped the way an interview actually flows — language first, then the runtime, then the web stack, then data, then scenarios. Every entry has a short answer here and links to the full explanation with a code example and the interviewer's likely follow-up questions.
It is a curated set that grows over time rather than a padded list of 100 near-duplicate links. Work top to bottom to prepare broadly, or jump to the section you are weakest on.
C# language
10 questionsC# is a modern, statically typed, object-oriented (and increasingly functional) programming language from Microsoft. It compiles to Intermediate Language (IL) that runs on the .NET runtime (the CLR), which…
Read detailed answerA value type (struct, enum, int, bool, DateTime) holds its data directly; assigning or passing it copies the value. A reference type (class, interface, array, delegate, string) holds a reference to an object…
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 answerAn abstract class is a base class you can't instantiate; it can hold state (fields), constructors, and a mix of implemented and abstract members, and a class can inherit only one. An interface is a contract —…
Read detailed answerA delegate is a type-safe reference to a method — effectively a function pointer with a signature. You can store methods in delegate variables, pass them as arguments, and invoke them later. Func<>, Action<>…
Read detailed answerLINQ (Language-Integrated Query) is a uniform way to query data — in-memory collections, databases, XML, JSON — using C# operators like Where, Select, OrderBy, GroupBy and Join, in either method syntax or…
Read detailed answerIEnumerable<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 answerBoth pass an argument by reference so the method can modify the caller's variable. ref requires the variable to be initialised before the call and the method may read it. out does not require initialisation…
Read detailed answerstring is immutable — every concatenation or modification allocates a new string object. StringBuilder is a mutable buffer; appends modify it in place (growing an internal array as needed). Use StringBuilder…
Read detailed answer.NET runtime & CLR
3 questionsThe CLR is the execution engine for .NET. It loads assemblies, JIT-compiles Intermediate Language (IL) to native machine code, enforces type safety, manages memory with the garbage collector, and provides…
Read detailed answerManaged code runs under the CLR, which handles memory, type safety and exceptions — normal C#/.NET code. Unmanaged code runs directly on the OS with no CLR services — C/C++ libraries, COM components, OS…
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 MVC
7 questionsASP.NET MVC is a web framework that implements the Model-View-Controller pattern. A controller handles the request, works with the model (the data and business logic), and returns a view (the HTML). It gives…
Read detailed answerThe request is matched by routing to a controller and action, the controller factory creates the controller, the action invoker runs authorization and action filters, performs model binding and validation,…
Read detailed answerRouting is the system that maps an incoming URL to a controller action, and (in reverse) generates URLs for a given action. You define routes either by convention (a pattern like {controller}/{action}/{id?})…
Read detailed answerActionResult is the base type for what a controller action returns. It represents a deferred command — “render this view”, “return this JSON”, “redirect there”, “send a 404” — that the framework executes…
Read detailed answerViewData is a string-keyed dictionary (ViewDataDictionary) for passing data from a controller to its view, valid for the current request only. ViewBag is a dynamic wrapper over the same dictionary — nicer…
Read detailed answerA strongly typed view declares the model type it expects with @model at the top. Inside, Model is that type, so you get IntelliSense, compile-time checking and strongly typed HTML/tag helpers like…
Read detailed answerYou annotate the model with validation attributes ([Required], [StringLength], [Range], [EmailAddress]…). During model binding the framework runs those rules and records failures in ModelState. Your action…
Read detailed answerASP.NET Core
8 questionsASP.NET Core is a free, open-source, cross-platform framework for building web apps, APIs and real-time services on .NET. It is a ground-up rewrite of ASP.NET that runs on Windows, Linux and macOS, is modular…
Read detailed answerASP.NET MVC 5 runs only on the Windows .NET Framework, is hosted in IIS through System.Web, and needs third-party libraries for dependency injection. ASP.NET Core is cross-platform, self-hosted through…
Read detailed answerMiddleware is a component that sits in the request pipeline. Each piece of middleware receives the HttpContext, can do work before and after the rest of the pipeline, and then either calls next() to pass the…
Read detailed answerA 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 answerKestrel is the default, cross-platform web server built into ASP.NET Core. It is a fast, lightweight HTTP server that listens for requests and hands them to your app's middleware pipeline. In production it is…
Read detailed answerDependency Injection (DI) is a design technique where a class receives the objects it depends on from the outside — usually through its constructor — instead of creating them itself. ASP.NET Core has a…
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 answerWeb API
5 questionsA RESTful API models the system as resources identified by URLs, manipulated with standard HTTP verbs (GET, POST, PUT, PATCH, DELETE), returning appropriate status codes and representations (usually JSON). It…
Read detailed answerGET reads a resource (safe, idempotent, cacheable). POST creates a resource or triggers processing (not idempotent). PUT replaces a resource entirely at a known URL (idempotent). PATCH applies a partial…
Read detailed answerAn MVC controller derives from Controller and typically returns a view (HTML) via view/model. A Web API controller derives from ControllerBase, is marked [ApiController], and returns data that is serialised…
Read detailed answerPick one scheme and be consistent: URL path (/api/v2/orders) — most visible and cache-friendly; query string (?api-version=2.0); header (api-version: 2.0) — keeps URLs clean; or media type (Accept:…
Read detailed answerFilters run code at specific stages of the MVC action pipeline, inside model binding and routing. The types, in order: Authorization → Resource → Action (before/after the action) → Exception → Result…
Read detailed answerEntity Framework
5 questionsEntity Framework Core is Microsoft's lightweight, cross-platform object-relational mapper (ORM) for .NET. It lets you work with a database using C# classes and LINQ instead of hand-written SQL: DbContext…
Read detailed answerCode First: you write the C# entity classes and configuration, and EF generates the database schema through migrations. Database First: the database already exists and you scaffold (reverse-engineer) the…
Read detailed answerEager 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 answerA migration is a versioned, code-generated description of a schema change. When you change your entity model, dotnet ef migrations add <Name> diffs the model against the last migration and writes Up()/Down()…
Read detailed answerSQL Server
8 questionsAn index is an on-disk structure (a B-tree) that lets SQL Server find rows without scanning the whole table. It stores the indexed column values in sorted order with pointers to the matching rows, so lookups,…
Read detailed answerA clustered index determines the physical order of the rows in the table — the leaf level of the index is the table data — so there can be only one. A non-clustered index is a separate structure; its leaf…
Read detailed answerAn INNER JOIN returns only rows that have a match in both tables. A LEFT JOIN (left outer join) returns every row from the left table, plus matching columns from the right table where they exist and NULLs…
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 answerA transaction is a unit of work that either fully completes or has no effect. ACID is the set of guarantees: Atomicity (all-or-nothing), Consistency (constraints hold before and after), Isolation (concurrent…
Read detailed answerDELETE is DML: removes rows (optionally with a WHERE), logs each row, fires triggers, keeps the table and can be rolled back. TRUNCATE is DDL: removes all rows by deallocating pages, minimally logged, very…
Read detailed answerA stored procedure is a named, precompiled batch of T-SQL saved in the database that you call with EXEC, optionally passing parameters. It centralises data logic, is parameterised (so it resists SQL…
Read detailed answerScenario & debugging
5 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 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 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 answer