.NET Interview Questions

What is .NET framework?

.NET framework is a software framework developed by Microsoft that provides a platform for building, deploying, and running applications and services. It includes a large library of pre-built code and supports multiple programming languages, making it versatile for developing a wide range of applications.

Explain the difference between managed code and unmanaged code in .NET.

Managed code in .NET is code that is executed by the Common Language Runtime (CLR), where the runtime manages memory and provides services like garbage collection. Unmanaged code, on the other hand, is not executed by the CLR and is responsible for managing its own memory and resources.

What is C#?

C# is a popular programming language developed by Microsoft as part of the .NET framework. It is a versatile language used for building a wide range of applications, from desktop to web to mobile. C# is known for its simplicity, flexibility, and robustness in creating efficient and scalable software solutions.

0+ jobs are looking for .NET Candidates

Curated urgent .NET openings tagged with job location and experience level. Jobs will get updated daily.


What are the main components of .NET framework?

The main components of the .NET framework include the Common Language Runtime (CLR), the Framework Class Library (FCL), and various development tools such as Visual Studio. CLR provides runtime environment for managed code, FCL provides reusable code libraries, and development tools enable creating, debugging, and deploying applications.

What are the different types of JIT compilers in .NET?

In .NET, there are two types of JIT (Just-In-Time) compilers: 1. Legacy JIT Compiler - compiles code on a method-by-method basis when it is first called. 2. RyuJIT Compiler - introduced in .NET Framework 4.5, it is a high-performance, optimizing JIT compiler that produces more efficient machine code.

What is the role of Common Language Runtime (CLR) in .NET?

The Common Language Runtime (CLR) in .NET is the virtual machine component responsible for managing the execution of .NET programs. It provides various services such as memory management, exception handling, type safety, and security enforcement, making it a crucial component for running and managing .NET applications.

Explain garbage collection in .NET.

Garbage collection in .NET is an automatic memory management process that periodically checks for objects that are no longer being used by the program and deallocates them. This helps free up memory and improve application performance by reducing memory leaks and manual memory management.

What is the Global Assembly Cache (GAC) in .NET?

The Global Assembly Cache (GAC) in .NET is a machine-wide repository for storing and sharing .NET assemblies. It allows multiple applications to use the same version of an assembly, ensuring that common libraries are not duplicated across the system and enabling easier version management.

What is an assembly in .NET?

In .NET, an assembly is a fundamental unit of deployment, versioning, and security. It is a collection of one or more files, such as DLLs or EXEs, that contain metadata and MSIL (Microsoft Intermediate Language) code that can be executed by the Common Language Runtime (CLR).

How does exception handling work in .NET?

In .NET, exception handling is done using try, catch, and finally blocks. When an exception occurs in the try block, the catch block catches it and handles the error. The finally block is used to ensure that certain code is always executed, regardless of whether an exception is thrown.

What are the different data access technologies available in .NET?

Some of the data access technologies available in .NET include ADO.NET, Entity Framework, LINQ to SQL, and Dapper. These technologies provide various ways to connect, query, and manipulate data from databases in .NET applications.

Explain the concept of namespaces in .NET.

In .NET, namespaces are used to organize and categorize classes, interfaces, and other types within a codebase. They help prevent naming conflicts and make it easier to manage and understand the structure of a project. Namespaces also enable developers to create reusable and modular code components.

What is the difference between value types and reference types in .NET?

Value types hold their data directly in memory, while reference types store a reference to the actual data in memory. Value types store their data on the stack, while reference types store their data on the heap and are accessed through a reference.

What is the purpose of the App.config file in .NET applications?

The App.config file in .NET applications is used to store application settings, connection strings, and other configuration data. It allows developers to easily modify settings without recompiling the application, making it easier to manage and customize the behavior of the application.

What is a delegate in .NET?

A delegate in .NET is a type that references a method. It allows methods to be passed as parameters, store methods in variables, and invoke methods at a later time. Delegates enable the implementation of callback methods and event handling in .NET applications.

Explain the use of LINQ in .NET.

LINQ (Language Integrated Query) in .NET is used to efficiently query data from different data sources such as databases, XML, collections, and more. It allows for writing SQL-like queries directly in code, providing a more natural and intuitive way to work with data in C#.

What is the role of the Globalization and Localization namespaces in .NET?

The Globalization namespace in .NET provides classes for handling culture-specific information such as dates, numbers, and currencies. The Localization namespace allows developers to create multilingual applications by providing resources and tools for translating text and adapting functionality for different languages and regions.

How can you secure a .NET application?

To secure a .NET application, you can use various techniques such as implementing proper authentication and authorization, encrypting sensitive data, using HTTPS for communication, avoiding SQL injection through parameterized queries, regular security audits, and staying up-to-date with security patches and updates.

What is the purpose of the web.config file in ASP.NET applications?

The web.config file in ASP.NET applications is used to store configuration settings for the application, such as database connection strings, session state settings, authentication and authorization rules, and custom application settings. It allows developers to easily modify and customize the behavior of the application without recompiling the code.

Explain the concept of multithreading in .NET.

Multithreading in .NET refers to the ability of a program to execute multiple threads simultaneously within the same application. This allows for improved performance and responsiveness by distributing tasks across multiple threads, enabling parallel processing and smoother user experience.

What is .NET framework?

.NET framework is a software framework developed by Microsoft that provides a platform for building, deploying, and running applications and services. It includes a large library of pre-built code and supports multiple programming languages, making it versatile for developing a wide range of applications.

The .NET Framework is a software framework developed by Microsoft that provides a comprehensive programming model for building applications for Windows, web, mobile, and cloud platforms. It is designed to support a wide range of programming languages, including C#, Visual Basic, and F#, allowing developers to create diverse types of applications.

The .NET Framework includes a large class library known as the Base Class Library (BCL), which provides a wide range of functionalities for common tasks such as file I/O, network communication, data access, and much more. In addition to the BCL, the framework also includes frameworks such as ASP.NET for web development, Windows Presentation Foundation (WPF) for building desktop applications, and Xamarin for cross-platform mobile development.

One of the key components of the .NET Framework is the Common Language Runtime (CLR), which provides services such as memory management, exception handling, and thread management. The CLR also performs intermediate language (IL) compilation and Just-In-Time (JIT) compilation to execute .NET applications.

The latest version of the .NET Framework is .NET Core, which is an open-source, cross-platform development framework that provides a high degree of flexibility and scalability. .NET Core can be used to build applications for Windows, macOS, and Linux, making it a versatile choice for developers targeting multiple platforms.

Here is a simple example demonstrating the use of the .NET Framework in C#:

using System;

class Program
    static void Main()
        Console.WriteLine("Hello, .NET Framework!");

Key Features of the .NET Framework:

  • Language Independence: Supports multiple programming languages through the Common Language Specification (CLS).
  • Interoperability: Allows communication between applications written in different languages.
  • Security: Implements security measures such as code access security to protect applications.
  • Performance: Utilizes JIT compilation and other optimizations for efficient execution.

The .NET Framework continues to evolve with updates and new features, empowering developers to build robust and scalable applications across various platforms.