🔷 .NET Interview Questions
Master .NET interviews with questions on C#, ASP.NET Core, Entity Framework, and the .NET ecosystem
15-Minute .NET Cheatsheet
Quick reference for last-minute interview preparation
🔷 C# Fundamentals
✨ Modern C# (8-12)
🌐 ASP.NET Core
🗃️ Entity Framework Core
⚡ Async Programming
🔍 LINQ Essentials
🔄 Dependency Injection Lifetimes
⚠️ Common Interview Gotchas
.NET Framework: Windows-only, legacy platform (up to version 4.8). Includes WPF, Windows Forms, ASP.NET. No longer actively developed for new features.
.NET Core: Cross-platform, open-source reimplementation (versions 1.0-3.1). Designed for cloud, microservices, and containers.
.NET 5+: Unified platform (5, 6, 7, 8, 9...). Combines .NET Framework and .NET Core. Cross-platform, modern, and the future of .NET. Even versions are LTS (Long-Term Support).
Records are reference types designed for immutable data models with value-based equality. Introduced in C# 9.0, they provide a concise syntax for creating data-centric types.
Key Differences:
- Records have value-based equality by default (classes have reference equality)
- Records support with-expressions for non-destructive mutation
- Records have built-in ToString() implementation
- Records are immutable by default (but can be made mutable)
async/await is C#'s syntax for asynchronous programming, making it easier to write non-blocking code. The Task Parallel Library (TPL) provides the foundation for parallel and asynchronous programming.
Dependency Injection (DI) is a design pattern where objects receive their dependencies from external sources rather than creating them. ASP.NET Core has built-in DI container that manages object lifetimes.
Service Lifetimes:
- Transient: Created each time they're requested
- Scoped: Created once per client request (HTTP request)
- Singleton: Created once for the application lifetime
LINQ (Language Integrated Query) provides a uniform way to query different data sources using C# syntax. It supports method syntax and query syntax for writing expressive queries.
Entity Framework Core is a modern Object-Relational Mapper (ORM) for .NET. It enables developers to work with databases using .NET objects, eliminating the need for most data-access code.
Middleware is software assembled into an application pipeline to handle requests and responses. Each component can perform operations before and after the next component in the pipeline.
Delegates: Type-safe function pointers that reference methods.
Events: Special delegates for the publisher-subscriber pattern.
Lambda Expressions: Anonymous functions for concise inline code.
Value Types: Stored on the stack, contain actual data (int, struct, enum).
Reference Types: Stored on the heap, contain reference to data (class, string, array).
IEnumerable<T>: In-memory collection, executes queries in-process using LINQ to Objects.
IQueryable<T>: Translates queries to external query language (e.g., SQL), executes on database.
The .NET Garbage Collector (GC) automatically manages memory allocation and release. It uses a generational algorithm with three generations (0, 1, 2) to optimize performance.
Pattern matching enables you to test whether a value has a certain shape and extract information from it. C# supports multiple pattern types introduced from C# 7.0 through C# 11.
Nullable Reference Types (C# 8.0+) help prevent null reference exceptions by making nullability explicit in the type system. The compiler warns about potential null references at compile time.
Span<T> and Memory<T> (C# 7.2+) provide type-safe, memory-efficient access to contiguous memory without allocations. Span is stack-only, while Memory can be used in async methods and stored in fields.
API versioning allows you to evolve your API while maintaining backward compatibility. ASP.NET Core supports multiple versioning strategies: URL path, query string, header, and media type.
🧠 Memory Management
.NET uses generational GC with three generations (0, 1, 2) and Large Object Heap for objects over 85KB.
🌐 ASP.NET Core Framework
Interview Tips for .NET
- ✓ Understand the evolution from .NET Framework to modern .NET
- ✓ Know async/await deeply - it's used everywhere in modern .NET
- ✓ Be familiar with Dependency Injection and service lifetimes
- ✓ Practice LINQ queries - both syntax styles
- ✓ Understand Entity Framework Core and database migrations
- ✓ Know modern C# features (records, pattern matching, null-safety)
- ✓ Be ready to discuss ASP.NET Core middleware pipeline
- ✓ Understand memory management, GC, and Span<T> for performance
- ✓ Know the difference between value types and reference types
- ✓ Be familiar with API versioning strategies