Introduction
If you are preparing for .NET interviews or learning C#, you will quickly notice a recurring pattern. Interviewers tend to ask the same topics repeatedly—not because they are meant to trick you, but because they reveal how well you understand real-world application behavior. Most beginners struggle with these questions because they encounter the problem first and learn the concept name later.
In this article, we break down five of the most confusing .NET interview questions, explain why they exist, and simplify them using clear, practical examples.
Why Do We Use Async and Await in .NET?
You may have faced situations where:
Even when your logic is correct, the application appears to wait. This happens because the program blocks a thread while waiting for slow operations such as I/O or database calls. async and await provide a non-blocking way to handle these delays.
Simple explanation:
Example:
public async Task<List<User>> GetUsers()
{
return await _context.Users.ToListAsync();
}
This allows the server to process other requests while waiting for the database response.
Interview takeaway: Async improves responsiveness and scalability by preventing thread blocking.
What Is Dependency Injection and Why Don’t We Use new Everywhere?
Beginners often wonder:
Who creates the object?
Where does it come from?
Consider the following service:
public class UserService
{
public string GetUser() => "User";
}
Now look at the controller:
public class UsersController : ControllerBase
{
private readonly UserService _service;
public UsersController(UserService service)
{
_service = service;
}
}
You never explicitly created UserService, yet it works. This behavior is known as Dependency Injection.
What is happening behind the scenes:
Why this matters:
Interview takeaway: Dependency Injection allows the framework to manage object creation instead of the developer.
What Are Service Lifetimes (Singleton, Scoped, Transient)?
Once Dependency Injection is understood, interviewers often ask about service lifetimes.
Example registration:
builder.Services.AddScoped<UserService>();
There are three commonly used lifetimes:
Transient
A new instance is created every time the service is requested.
AddTransient<UserService>();
Scoped
One instance is created per HTTP request. This is the recommended option for APIs.
AddScoped<UserService>();
Singleton
A single instance is created for the entire lifetime of the application.
AddSingleton<UserService>();
Common interview question: Which lifetime should DbContext use?
Correct answer: Scoped, because it is tied to a single request.
What Is the Difference Between IEnumerable, IQueryable, and List?
This question confuses many beginners because all three are often used interchangeably.
Example:
IEnumerable<User> users = _context.Users;
Key differences:
List: Data is already loaded into memory
IEnumerable: Data is loaded when iteration begins
IQueryable: The query is built and executed in the database
Example:
var users = _context.Users.Where(u => u.IsActive);
With IQueryable:
Interview takeaway: Use IQueryable for database queries and List for in-memory operations.
What Is Middleware in ASP.NET Core?
Middleware is code that executes before or after a request is handled by the application. It forms the request-processing pipeline in ASP.NET Core.
Example:
app.Use(async (context, next) =>
{
Console.WriteLine("Request started");
await next();
Console.WriteLine("Response sent");
});
What happens in the pipeline:
Request enters the application
Middleware executes
Request reaches the controller
Response flows back through middleware
Common use cases:
Interview takeaway: Middleware handles cross-cutting concerns within the request pipeline.
Conclusion
These five questions cover a significant portion of what interviewers expect from a .NET developer. Understanding why these concepts exist is far more valuable than memorizing definitions. Once these fundamentals are clear, .NET interviews become much more approachable and confidence-inspiring.