.NET Framework and .NET Core
.NET Framework and .NET Core Interview with follow-up questions
1. What is the .NET Framework and why is it used?
.NET Framework (versions 1.0–4.8.1) is Microsoft's original managed development platform, released in 2002. It is now in maintenance mode — security patches only, no new features.
What .NET Framework included:
- CLR (Common Language Runtime) for managed code execution
- FCL (Framework Class Library) — the
System.*APIs - ASP.NET (Web Forms, MVC 5) for web development
- WCF (Windows Communication Foundation) for SOAP services
- WPF and WinForms for desktop GUIs
- Entity Framework (up to EF 6)
Critical context for 2025-2026 interviews:
The platform has evolved:
| Era | Platform | Status |
|---|---|---|
| 2002–2019 | .NET Framework (1.0–4.8.1) | Legacy, Windows-only |
| 2016–2019 | .NET Core (1.0–3.1) | Cross-platform reboot |
| 2020–present | .NET 5, 6, 7, 8, 9 | Current unified platform |
The modern platform is simply ".NET" — currently .NET 9 (released November 2024). All new development should target .NET 9 (or .NET 8 LTS, supported until November 2026).
Why .NET Framework still appears in interviews:
- Millions of enterprise applications run on it (Windows Services, legacy Web Forms apps)
- Migration to modern .NET is a common project type — interviewers test your awareness of the differences
- The Windows-only constraint, the GAC (Global Assembly Cache), full-trust only, and non-modular nature are all .NET Framework limitations that modern .NET resolves
Interviewers probe: should new projects target .NET Framework? No — use .NET 9. The only reason to choose .NET Framework today is maintaining an existing application that cannot be migrated (e.g., depends on Windows-only COM components not yet ported).
Follow-up 1
Can you explain the architecture of .NET Framework?
The architecture of the .NET Framework is based on a layered approach. At the core of the framework is the Common Language Runtime (CLR), which provides services such as memory management, exception handling, and security. On top of the CLR, there are various libraries and frameworks, including the Base Class Library (BCL), which provides a set of reusable classes and types, and the Framework Class Library (FCL), which includes additional libraries for specific application types. The .NET Framework also includes a set of development tools, such as compilers and debuggers, to aid in the development process.
Follow-up 2
What are the main components of .NET Framework?
The main components of the .NET Framework include:
Common Language Runtime (CLR): The CLR is the execution engine that manages the execution of .NET applications. It provides services such as memory management, garbage collection, and exception handling.
Base Class Library (BCL): The BCL is a collection of classes, interfaces, and value types that provide common functionality to .NET applications. It includes classes for file I/O, networking, data access, and more.
Framework Class Library (FCL): The FCL is an extension of the BCL and includes additional libraries for specific application types, such as Windows Forms, ASP.NET, and WPF.
Development Tools: The .NET Framework includes a set of development tools, such as compilers, debuggers, and integrated development environments (IDEs), to aid in the development process.
Follow-up 3
What are the advantages of using .NET Framework?
There are several advantages of using the .NET Framework:
Language Independence: The .NET Framework supports multiple programming languages, such as C#, VB.NET, and F#, allowing developers to choose the language that best suits their needs.
Platform Independence: Applications developed using the .NET Framework can run on multiple platforms, including Windows, web, mobile, and cloud.
Rapid Development: The .NET Framework provides a rich set of libraries and tools that simplify the development process, allowing developers to build applications more quickly and efficiently.
Security: The .NET Framework includes built-in security features, such as code access security and role-based security, to help protect applications from unauthorized access and malicious code.
Interoperability: The .NET Framework supports interoperability with existing code and systems, allowing developers to integrate .NET applications with legacy systems and third-party libraries.
Scalability: The .NET Framework is designed to handle large-scale applications and can scale to meet the needs of enterprise-level applications.
Community and Support: The .NET Framework has a large and active community of developers, with a wealth of resources and support available.
2. What is .NET Core and how does it differ from .NET Framework?
.NET Core was Microsoft's cross-platform, open-source reimplementation of .NET, released in 2016. As of .NET 5 (2020), the "Core" name was dropped — the product is now simply ".NET".
The evolution:
| Version | Year | Notes |
|---|---|---|
| .NET Core 1.0–1.1 | 2016 | First cross-platform release |
| .NET Core 2.0–2.2 | 2017–2018 | Major API completeness improvements |
| .NET Core 3.0–3.1 | 2019 | Added WinForms/WPF support, became LTS |
| .NET 5 | 2020 | Unified platform, dropped "Core" name |
| .NET 6 | 2021 | LTS, minimal APIs, top-level statements default |
| .NET 7 | 2022 | Native AOT, rate limiting |
| .NET 8 | 2023 | LTS, primary constructors, collection expressions |
| .NET 9 | 2024 | Current, Task.WhenEach, Lock type, C# 13 |
| .NET 10 | 2025 | Preview (LTS planned, expected Nov 2025) |
Key differences from .NET Framework:
| .NET (modern) | .NET Framework |
|---|---|
| Cross-platform (Win/Mac/Linux/ARM64) | Windows only |
| Open source | Partially open |
| Side-by-side installation | Machine-wide GAC |
| Modular, trimmable | Monolithic |
| Native AOT support | No |
| Significantly faster (benchmarks) | Slower |
| No Web Forms, WCF server | Had them |
Current recommendation: target .NET 8 (LTS) for production apps needing long-term support, or .NET 9 for the latest features. .NET 10 (LTS) is in preview.
Interviewers probe: what is the difference between .NET Framework and .NET today? .NET Framework is the legacy Windows-only platform; ".NET" is the modern cross-platform successor. ".NET Core" is a historical name for versions 1.0–3.1 before the unification.
Follow-up 1
What are the advantages of using .NET Core?
There are several advantages of using .NET Core:
Cross-platform compatibility: .NET Core can run on Windows, macOS, and Linux, allowing developers to build applications that can run on multiple operating systems.
Performance: .NET Core is designed to be lightweight and optimized for performance. It has a smaller memory footprint and faster startup times compared to .NET Framework.
Open-source and community-driven: .NET Core is open-source and has a large community of developers contributing to its development. This means that there are a lot of resources, libraries, and tools available for developers to use.
Microservices architecture: .NET Core is well-suited for building microservices-based architectures, where applications are broken down into smaller, independent services that can be developed, deployed, and scaled independently.
Containerization: .NET Core has built-in support for containerization using technologies like Docker, making it easier to package and deploy applications in a containerized environment.
Follow-up 2
Can you explain the architecture of .NET Core?
The architecture of .NET Core is based on a modular design. At the core of .NET Core is the Common Language Runtime (CLR), which provides the runtime environment for executing .NET Core applications. On top of the CLR, there are various libraries and frameworks that provide functionality for building different types of applications, such as ASP.NET Core for web applications and Entity Framework Core for database access.
.NET Core applications are typically built using a combination of C# or F# for the application logic and Razor for the user interface. The applications can be deployed as self-contained executables or as cross-platform libraries that can be used by other applications.
The modular design of .NET Core allows developers to include only the components they need, resulting in smaller application sizes and improved performance.
Follow-up 3
In what scenarios would you prefer .NET Core over .NET Framework?
There are several scenarios where .NET Core is preferred over .NET Framework:
Cross-platform development: If you need to build applications that can run on multiple operating systems, such as Windows, macOS, and Linux, then .NET Core is the preferred choice. .NET Framework can only run on Windows.
Performance-critical applications: If you need to build applications that require high performance and have strict performance requirements, then .NET Core is a better choice. It has a smaller memory footprint and faster startup times compared to .NET Framework.
Microservices architecture: If you are building a microservices-based architecture, where applications are broken down into smaller, independent services, then .NET Core is well-suited for this scenario. It allows you to develop, deploy, and scale each service independently.
Containerization: If you are planning to use containerization technologies like Docker to package and deploy your applications, then .NET Core has built-in support for containerization, making it easier to work with containers.
3. What is Entity Framework in C#?
Entity Framework Core (EF Core) is the current, cross-platform object-relational mapper (ORM) for .NET. The old EF6 (Entity Framework 6) targeted .NET Framework and is in maintenance mode — modern projects use EF Core.
Key concepts:
// Entity (POCO class)
public class Order
{
public int Id { get; set; }
public string CustomerName { get; set; } = string.Empty;
public List Items { get; set; } = new();
}
// DbContext — unit of work + session
public class AppDbContext : DbContext
{
public DbSet Orders { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity().HasIndex(o => o.CustomerName);
}
}
Two development approaches:
- Code-First: define C# entity classes, generate database schema via migrations (
dotnet ef migrations add,dotnet ef database update) - Database-First: scaffold entity classes from an existing database (
dotnet ef dbcontext scaffold)
Querying:
// Async queries — always prefer async in production
var orders = await db.Orders
.Where(o => o.CustomerName == "Alice")
.Include(o => o.Items) // eager load related data
.AsNoTracking() // read-only; better performance
.ToListAsync();
Change tracking and saving:
var order = new Order { CustomerName = "Bob" };
db.Orders.Add(order);
await db.SaveChangesAsync(); // translates to INSERT
EF Core 9 highlights: improved JSON column mapping, ComplexType for owned types, better SQL generation.
EF Core vs Dapper: EF Core handles the full ORM lifecycle (migrations, change tracking, lazy loading); Dapper is a micro-ORM that maps raw SQL results to objects — preferred when you need full SQL control, stored procedures, or maximum read throughput.
Database providers: SQL Server (UseSqlServer), PostgreSQL (UseNpgsql), SQLite (UseSqlite), MySQL, CosmosDB, and more.
Interviewers probe: what is AsNoTracking() and when do you use it? EF Core tracks loaded entities to detect changes for SaveChanges(). AsNoTracking() skips tracking — use it for all read-only queries; it's faster and uses less memory.
Follow-up 1
What are the main features of Entity Framework?
Entity Framework offers several key features that make it a popular choice for data access in C# applications:
Object-Relational Mapping (ORM): Entity Framework allows developers to map database tables to .NET classes, and database columns to class properties. This enables seamless interaction between the application and the database, without the need for writing complex SQL queries.
LINQ Support: Entity Framework supports Language Integrated Query (LINQ), which allows developers to write queries using C# or Visual Basic syntax. This provides a strongly-typed and compile-time checked way to query data, improving code readability and reducing errors.
Automatic Change Tracking: Entity Framework automatically tracks changes made to objects and generates the necessary SQL statements to persist those changes to the database. This simplifies the process of updating, inserting, and deleting data.
Database Migrations: Entity Framework includes a feature called migrations, which allows developers to easily update the database schema as the application evolves. Migrations can be used to create, modify, or delete database tables, columns, and relationships.
Support for Multiple Database Providers: Entity Framework supports multiple database providers, including SQL Server, MySQL, PostgreSQL, and SQLite. This allows developers to work with different databases using a consistent API and codebase.
Follow-up 2
What are the advantages of using Entity Framework?
There are several advantages of using Entity Framework for data access in C# applications:
Productivity: Entity Framework simplifies the process of working with databases by providing a high-level abstraction over the underlying data access code. This allows developers to focus on writing business logic instead of dealing with low-level database operations.
Maintainability: Entity Framework promotes a modular and maintainable code structure by separating the data access logic from the rest of the application. This makes it easier to make changes to the data access layer without impacting other parts of the application.
Performance: Entity Framework includes features like query optimization and caching, which can improve the performance of data access operations. Additionally, Entity Framework allows developers to write efficient queries using LINQ, which are translated into optimized SQL statements.
Testability: Entity Framework supports unit testing by allowing developers to mock the data access layer. This makes it easier to write automated tests for the application, ensuring that the data access code behaves as expected.
Cross-Platform Compatibility: Entity Framework supports multiple database providers, making it possible to develop applications that can work with different databases. This provides flexibility and allows developers to choose the database that best suits their needs.
Follow-up 3
Can you explain the concept of Code-First in Entity Framework?
Code-First is an approach in Entity Framework where the database schema is generated based on the classes and relationships defined in code. With Code-First, developers start by writing the domain classes and their relationships, and Entity Framework takes care of creating the corresponding database schema.
To use Code-First in Entity Framework, developers need to follow these steps:
Define the domain classes: Create classes that represent the entities in the application's domain. These classes can include properties, methods, and relationships with other entities.
Configure the classes: Use data annotations or Fluent API to configure the classes and define additional metadata, such as primary keys, foreign keys, and indexes.
Create a DbContext: Create a class that inherits from the DbContext class provided by Entity Framework. This class represents the database context and acts as a bridge between the application and the database.
Enable migrations: Enable the migrations feature in Entity Framework to manage changes to the database schema over time. Migrations allow developers to create, modify, or delete database objects without losing data.
Generate the database: Use Entity Framework's migration commands to generate the database based on the defined classes and relationships. Entity Framework will create the necessary tables, columns, and relationships in the database.
Code-First in Entity Framework provides a flexible and code-centric approach to database development, allowing developers to focus on the domain model and write clean and maintainable code.
4. Can you explain the concept of CLR in .NET Framework?
CLR (Common Language Runtime) is the virtual machine at the heart of .NET. It executes managed code and provides services that make .NET languages safe, productive, and interoperable. The modern .NET runtime is called CoreCLR — an evolution of the original CLR, redesigned for cross-platform and performance.
Core CLR responsibilities:
1. JIT Compilation CIL (Common Intermediate Language) bytecode — the output of the C# compiler — is JIT-compiled to native machine code at runtime. Modern .NET uses tiered JIT:
- Tier 0: fast initial compilation
- Tier 1: optimized recompilation of hot methods after profiling
- Dynamic PGO (.NET 6+): profile-guided optimization adjusts code at runtime for actual usage patterns
2. Garbage Collection (GC) Generational: Gen0 (short-lived), Gen1 (survived one collection), Gen2 (long-lived), LOH (Large Object Heap, objects > 85KB). .NET 9 introduces DATAS (Dynamic Adaptation to Application Sizes) for improved GC scaling.
3. Type Safety The CLR enforces the type system at runtime — no out-of-bounds array access in managed code, no type confusion.
4. Exception Handling Structured exception handling across languages — catch blocks, finally blocks, and exception filters work consistently.
5. Thread Management Thread pool (adaptive sizing), synchronization primitives, and async I/O completion ports.
6. Interoperability P/Invoke for calling native C libraries, COM interop for Windows COM objects.
What CIL is: the intermediate bytecode that all .NET languages compile to. Because C#, F#, and VB.NET all emit CIL, they interoperate at the assembly level without any bridging layer.
Native AOT (.NET 7+): optional mode that compiles directly to native binaries at build time — no CLR JIT needed at runtime. Produces faster startup and smaller binaries but restricts reflection and runtime code generation.
Interviewers probe: what is managed vs unmanaged code? Managed code runs under CLR control (memory managed, type-safe). Unmanaged code is native C/C++ — called via P/Invoke or unsafe blocks, requiring manual memory management.
Follow-up 1
What is the role of CLR in .NET Framework?
The main role of CLR in .NET Framework is to provide a runtime environment for executing managed code. It manages the execution of .NET programs, including memory management, security, exception handling, and thread management. CLR also provides services such as garbage collection, just-in-time (JIT) compilation, and type safety verification.
Follow-up 2
What are the main components of CLR?
The main components of CLR are:
- Just-in-time (JIT) compiler: It compiles the Intermediate Language (IL) code into native machine code at runtime.
- Garbage Collector: It automatically manages the memory used by .NET programs, freeing up memory that is no longer needed.
- Security Manager: It enforces security policies to ensure that .NET programs run in a secure environment.
- Exception Manager: It handles exceptions that occur during the execution of .NET programs.
- Thread Manager: It manages the execution of threads in .NET programs, including thread synchronization and coordination.
Follow-up 3
What is the difference between CLR and CTS in .NET Framework?
CLR (Common Language Runtime) and CTS (Common Type System) are two important components of the .NET Framework.
CLR is the runtime environment that manages the execution of .NET programs, while CTS is a set of rules that define how types are declared, used, and managed in .NET programs.
In other words, CLR provides the runtime environment for executing managed code, while CTS provides the rules for defining and using types in .NET programs.
CLR includes components such as the just-in-time (JIT) compiler, garbage collector, security manager, exception manager, and thread manager.
CTS defines the rules for declaring and using types, including classes, structures, interfaces, and enumerations. It ensures that types defined in different .NET languages can interoperate seamlessly.
5. What is the role of the .NET runtime in .NET Core?
In modern .NET (formerly .NET Core), the runtime is CoreCLR — a cross-platform, open-source evolution of the original CLR. It provides the infrastructure that all .NET code runs on.
Key roles:
JIT compilation with tiered optimization: CIL bytecode → native code via a two-tier JIT:
- Tier 0: quick native code for first call
- Tier 1: re-JIT optimized version after profiling identifies hot methods
- Dynamic PGO (.NET 6+): runtime profiling feeds back into subsequent JIT passes for even better optimization (inlining decisions, branch prediction, type specialization)
Garbage Collector:
- Workstation GC (default for apps): lower latency, occasional pauses
- Server GC (default for ASP.NET Core): higher throughput, one heap per CPU core
- Low-latency GC modes:
GCSettings.LatencyModefor real-time scenarios - .NET 9 DATAS: dynamically adapts heap sizes to application working set
Assembly loading:
Loads .dll assemblies on demand. AssemblyLoadContext enables plugin isolation (load/unload assemblies at runtime). Source generators (C# 9+) are preferred over runtime Reflection.Emit for AOT compatibility.
Thread pool:
Adaptive sizing based on throughput — starts with a small pool, adds threads when all are busy (with a delay to avoid overprovisioning). ThreadPool.SetMinThreads() can pre-warm for bursty loads.
Native AOT (.NET 7+):
Compiles the entire application — including the runtime itself — to a single native binary at build time. No JIT, no CLR at runtime. Benefits: ~10ms startup vs ~100ms for JIT, minimal memory footprint. Trade-offs: no runtime Assembly.Load, limited reflection (use source generators instead), larger binary for small apps.
Platform support: x64, x86, ARM32, ARM64, RISC-V (experimental), LoongArch (.NET 9+).
Interviewers probe: what is the difference between JIT and AOT? JIT compiles at startup/first-call with runtime profiling data; AOT compiles at build time with static analysis only. JIT can produce better optimized code for long-running processes; AOT wins on startup time and memory footprint.
Follow-up 1
How does .NET runtime work in .NET Core?
The .NET runtime in .NET Core works by loading and executing the compiled .NET Core code. When a .NET Core application is launched, the runtime first loads the necessary libraries and dependencies, and then starts executing the entry point of the application. It manages the memory allocation and deallocation, performs garbage collection to reclaim unused memory, and handles exceptions that occur during the execution of the application.
Follow-up 2
What is the difference between .NET runtime and .NET Framework?
The main difference between .NET runtime and .NET Framework is that .NET runtime is a component of .NET Core, while .NET Framework is a full-fledged development framework for building Windows applications. .NET runtime provides the runtime environment for executing .NET Core applications, whereas .NET Framework includes not only the runtime, but also a large set of libraries and APIs for developing various types of applications.
Follow-up 3
What are the advantages of using .NET runtime in .NET Core?
There are several advantages of using .NET runtime in .NET Core:
Cross-platform compatibility: .NET Core and its runtime are designed to be cross-platform, allowing developers to build and run applications on different operating systems.
Performance: The .NET runtime in .NET Core is optimized for performance, providing faster startup times and improved overall performance compared to the .NET Framework.
Modularity: .NET Core and its runtime are designed to be modular, allowing developers to include only the necessary components and dependencies in their applications, resulting in smaller and more lightweight applications.
Open-source and community-driven: .NET Core and its runtime are open-source projects, which means that developers can contribute to the development and improvement of the runtime, and benefit from the contributions of the community.
Live mock interview
Mock interview: .NET Framework and .NET Core
- Read your scene and goals
- Talk it out; goals tick off live
- Get a score and stronger lines
Your voice and your AI key never touch our servers; the key stays in this browser and is sent only to Google. Only your round scores are saved to track progress.