.NET is a cross-platform framework used for enterprise web APIs, cloud services, desktop apps and games, so .NET interview questions and C# interview questions are essential for .NET developer, full stack and backend roles. This guide covers the top 20 questions and answers on C#, the CLR, ASP.NET Core, Entity Framework Core and performance.
It works for freshers learning the basics and experienced .NET developers preparing for senior or lead interviews.
C# and .NET fundamentals
1. What is .NET and how is it different from .NET Framework?
.NET Framework is the older Windows-only runtime. Modern .NET (formerly .NET Core, now .NET 8, 9 and later) is open source, cross-platform, faster, container friendly and the platform for all new development, with long-term support (LTS) releases every two years.
2. What are the CLR, CTS and JIT?
The Common Language Runtime executes managed code and handles memory, type safety, exceptions and threading. The Common Type System defines types shared across .NET languages. The JIT compiler turns IL into machine code at runtime; ReadyToRun and Native AOT can compile ahead of time.
3. Value types vs. reference types?
Value types (int, bool, struct, enum) hold data directly and are copied on assignment. Reference types (class, string, array, delegate) hold a reference to an object on the managed heap. Boxing converts a value type to object and has a performance cost.
4. What is the difference between class, struct and record?
Classes are reference types with identity. Structs are value types suited to small, immutable data. Records (record class or record struct) provide value-based equality, concise syntax, immutability with init and non-destructive mutation with with.
5. Interface vs. abstract class?
An abstract class can hold state, constructors and implemented members, and a class can inherit only one. An interface defines a contract a class can implement many of, and can now include default implementations. Use interfaces for capabilities and testability.
Async, LINQ and memory
6. How do async and await work in C#?
async methods return Task or ValueTask and use await to free the thread while waiting for I/O. The compiler builds a state machine that resumes when the task completes. Avoid async void except for event handlers and never block with .Result or .Wait(), which can deadlock.
7. Task vs. Thread?
A Thread is an OS-level thread. A Task represents an asynchronous operation that usually runs on the thread pool or no thread at all for I/O. Tasks are lighter and composable with Task.WhenAll and cancellation tokens.
8. What is LINQ and what is deferred execution?
Language Integrated Query lets you query collections, databases and XML with a common syntax. Most LINQ operators are deferred: the query runs only when enumerated, such as with ToList() or foreach. IEnumerable runs in memory, while IQueryable is translated to SQL by EF Core.
9. How does garbage collection work in .NET?
The GC manages the heap in generations 0, 1 and 2 plus the large object heap, collecting short-lived objects quickly. Unmanaged resources such as file handles and connections should be released with IDisposable and using statements.
10. What are Span<T> and Memory<T>?
They represent contiguous memory without copying, allowing high-performance slicing of arrays, strings and buffers. Span<T> is stack-only; Memory<T> can be stored on the heap and used across awaits.
ASP.NET Core
11. What is middleware in ASP.NET Core?
Middleware components form the request pipeline configured in Program.cs. Each can handle the request, call the next component or short-circuit. Order matters: exception handling, HTTPS redirection, routing, CORS, authentication, authorization, then endpoints.
12. How does dependency injection work in ASP.NET Core?
A built-in container registers services with lifetimes: Transient (new each time), Scoped (one per request) and Singleton (one per app). Do not inject scoped services into singletons. Constructor injection is the norm.
13. Minimal APIs vs. controllers?
Minimal APIs map endpoints with lambdas in a few lines and are fast and ideal for microservices. Controllers suit larger APIs that benefit from filters, conventions and model binding organization. Both share routing, DI, validation and OpenAPI support.
14. How do you implement authentication and authorization?
Use JWT bearer or cookie authentication, OpenID Connect with Entra ID or another identity provider, ASP.NET Core Identity for local accounts, and policy-based authorization with [Authorize] attributes, roles and claims.
15. How do you handle configuration and secrets?
Configuration comes from appsettings.json, environment-specific files, environment variables and command-line arguments, bound with the Options pattern (IOptions<T>). Store secrets in User Secrets locally and Azure Key Vault or another secret manager in production.
Entity Framework Core and testing
16. What is Entity Framework Core?
EF Core is .NET’s ORM. You define entities and a DbContext, query with LINQ, and manage schema with migrations. It supports SQL Server, PostgreSQL, MySQL, SQLite and Cosmos DB.
17. How do you improve EF Core performance?
Use AsNoTracking for read-only queries, project to DTOs with Select, avoid N+1 queries with Include or split queries, add indexes, use compiled queries, batch updates with ExecuteUpdate/ExecuteDelete, and log generated SQL.
18. How do you test .NET applications?
Unit test with xUnit, NUnit or MSTest and mock with Moq or NSubstitute; integration test APIs with WebApplicationFactory; use Testcontainers for real databases; and run tests in CI with code coverage.
Scenario questions
19. Scenario: an ASP.NET Core API becomes unresponsive under load. What do you check?
Look for thread pool starvation from sync-over-async code (.Result, .Wait()), slow database queries, exhausted connection pools, missing timeouts on HttpClient calls (use IHttpClientFactory), and memory pressure. Use dotnet-counters, dotnet-trace and Application Insights to diagnose.
20. Scenario: how would you migrate a legacy .NET Framework app to modern .NET?
Assess with the .NET Upgrade Assistant, update libraries to .NET Standard or modern packages, replace Windows-only APIs, move from Web API/MVC to ASP.NET Core incrementally (strangler pattern with YARP), containerize, and add automated tests before refactoring.
How to prepare for a .NET interview
- Build an ASP.NET Core Web API with EF Core, authentication, validation, logging and tests.
- Review C# features from recent versions: records, pattern matching, nullable reference types, primary constructors and collection expressions.
- Practice async/await and LINQ questions with code.
- Know how to deploy to Azure App Service, containers or Kubernetes.
See also Azure interview questions, SQL interview questions and Angular or React guides for full stack roles.
Frequently asked questions
What .NET topics are asked most in interviews?
OOP in C#, value vs. reference types, async/await, LINQ, dependency injection, ASP.NET Core middleware, EF Core, exception handling and testing.
What is asked for senior .NET developers?
Architecture (clean architecture, microservices), performance profiling, memory management, security, cloud deployment on Azure and leading migrations from .NET Framework.
Should I learn .NET 8 or a newer version?
Learn the current LTS release and know what changed in recent versions. Most concepts carry over between releases.
Got the interview? Make sure your resume tells the same story.
Interviewers read your resume right before they talk to you. HiReXL aligns it with the job description’s keywords so your experience and your answers match. HiReXL is built by 4As Consulting, a cloud and DevOps consulting firm. Looking for your next role? Submit your resume for open positions with PanAmerica Inc.


