.NET Interview Questions

1.What is .NET Framework?

.NET Framework is a software development platform developed by Microsoft.
It provides a controlled environment for building, deploying, and running applications, primarily on Windows.

βœ… Key Features:

  • CLR (Common Language Runtime): Manages code execution, memory, garbage collection, etc.

  • BCL (Base Class Library): Offers a rich set of pre-built libraries for tasks like file I/O, networking, data access, etc.

  • Language Interoperability: Supports multiple languages like C#, VB.NET, F#.

  • Windows-Only: Unlike .NET Core or .NET 5+, the .NET Framework runs only on Windows OS.

βœ… Common Use Cases:

  • Web applications using ASP.NET

  • Desktop applications using Windows Forms or WPF

  • Enterprise software for internal tools and services

2.What is the difference between .NET Framework and .NET Core?

  • .NET Framework is best for legacy Windows-based enterprise applications.

  • .NET Core / .NET 5+ is the future of .NETβ€”it's modern, lightweight, and cross-platform.

3.What is CLR (Common Language Runtime)?

CLR (Common Language Runtime) is the core execution engine of the .NET Framework. It provides a managed execution environment for .NET programs, handling essential services like:

βœ… Key Responsibilities of CLR:

  • Memory Management: Automatically allocates and frees memory using Garbage Collection (GC).

  • Code Execution: Converts MSIL (Microsoft Intermediate Language) to native code using JIT (Just-In-Time)

    compilation.

  • Security: Enforces code access security (CAS) and type safety.

  • Exception Handling: Provides a structured mechanism to catch and handle errors.

  • Thread Management: Manages multiple threads and supports parallelism.

  • Interoperability: Supports interaction with COM objects and native code.

πŸ” CLR Workflow:

  1. C#/VB.NET code is compiled into MSIL.

  2. MSIL is executed by the CLR with Just-In-Time (JIT) compilation.

  3. CLR ensures the app runs in a secure and managed environment.

4.What are Value Types and Reference Types in C#?

In C#, data types are categorized into value types and reference types, and they differ in how they store data in memory.

βœ… Value Types:

  • Stored directly in the stack.

  • Hold the actual data.

  • When assigned to a new variable, the data is copied.

  • Faster to access.











βœ… Reference Types:

  • Stored in the heap, and the reference (memory address) is stored in the stack.

  • Hold the address of the data.

  • When assigned, both variables refer to the same object.

  • Changes via one reference affect the original.



Note: string is a reference type, but it behaves like a value type due to immutability.