30+ .NET Interview Questions (2021) - InterviewBit

Before you go!

Take this ".NET Interview Questions" interview guide with you

Welcome to Interviewbit, help us create the best experience for you!

Currently, You are a:

Few details about your education

College/University *
Enter the name of your college
Branch *
Year of completion *

Few details about your education

College/University *
Enter the name of your college
Branch *
Year of completion *

Few details about your career...

Current Company *
Enter company name
Experience *

You're all set!

Begin your success journey!

Sign Up using
Full name *
Email *
Password *

By creating an account, I acknowledge that I have read and agree to InterviewBit’s Terms and Privacy Policy .

Welcome back!

Log In using
Email *
Password *

.NET Interview Questions

Download PDF

Your requested download is ready!
Click here to download.

Begin your success journey!

Sign Up using
Full name *
Email *
Password *

By creating an account, I acknowledge that I have read and agree to InterviewBit’s Terms and Privacy Policy .

Welcome back!

Log In using
Email *
Password *

.NET framework is developed by Microsoft which provides an environment to run, debug and deploy code onto web services and applications by using tools and functionalities like libraries, classes, and APIs. It supports different languages like C#, Cobol, VB, Perl, etc.

Main components of .NET framework

.NET framework consists of 2 main components. They are:

  • Common Language Runtime- It is an execution engine that runs the code and provides services that make the development process easier.
  • Framework Class Library- It has pre-defined methods and properties to implement common and complex functions that can be used by .NET applications.

How does the .NET framework work?

  • .NET framework-based applications that are written in supportive languages like C#, F#, or Visual basic are compiled to Common Intermediate Language (CIL).
  • Compiled code is stored in the form of an assembly file that has a .dll or .exe file extension.
  • When the .NET application runs, Common Language Runtime (CLR) takes the assembly file and converts the CIL into machine code with the help of the Just In Time(JIT) compiler.
    Now, this machine code can execute on the specific architecture of the computer it is running on.
How .NET works?
Crack your next tech interview with confidence!
Take a free mock interview, get instant⚡️ feedback and recommendation💡

.NET Interview Questions For Freshers

1. What is CTS?

CTS stands for Common Type System. It follows a set of structured rules according to which a data type should be declared and used in the program code. It is used to describe all the data types that are going to be used in the application.

We can create our own classes and functions by following the rules in the CTS. It helps in calling the data type declared in one programming language by other programming languages.

2. Explain CLS

Common Language Specification (CLS) helps the application developers to use the components that are inter-language compatible with certain rules that come with CLS. It also helps in reusing the code among all of the .NET-compatible languages.

3. What is JIT?

JIT stands for Just In Time. It is a compiler that converts the intermediate code into the native language during the execution.

You can download a PDF version of Dot Net Interview Questions.

Download PDF

Your requested download is ready!
Click here to download.

4. What is the difference between int and Int32?

There is no difference between int and Int32. Int32 is a type provided by the .NET framework class whereas int is an alias name for Int32 in the C# programming language.

5. Explain the differences between value type and reference type.

The main differences between value type and reference type are given below:

  • A Value Type holds the actual data directly within the memory location and a reference type contains a pointer which consists of the address of another memory location that holds the actual data.
  • Value type stores its contents on the stack memory and reference type stores its contents on the heap memory.
  • Assigning a value type variable to another variable will copy the value directly and assigning a reference variable to another doesn’t copy the value, instead, it creates a second copy of the reference.
  • Predefined data types, structures, enums are examples of value types. Classes, Objects, Arrays, Indexers, Interfaces, etc are examples of reference types.

6. What is the difference between managed and unmanaged code?

The main difference between managed and unmanaged code is listed below:

Managed Code Unmanaged Code
It is managed by CLR. It is not managed by CLR.
.NET framework is a must for execution. Does not require a .NET framework for the execution.
Memory management is done through garbage collection. Runtime environment takes care of memory management.

7. Explain Microsoft Intermediate Language

MSIL is the Microsoft Intermediate Language, which provides instructions for calling methods, memory handling, storing and initializing values, exception handling, and so on.

The instructions provided by MSIL are platform-independent and are generated by the language-specific compiler from the source code. JIT compiler compiles the MSIL into machine code based on the requirement.

8. What is an assembly?

An assembly is a file that is automatically generated by the compiler which consists of a collection of types and resources that are built to work together and form a logical unit of functionality. We can also say, assembly is a compiled code and logical unit of code.

Assemblies are implemented in the form of executable (.exe) or dynamic link library (.dll) files.

.NET Intermediate Questions

9. Is ASP.NET different from ASP? If yes, explain how?

Yes, ASP.NET and ASP(Active Server Pages) both are different. Let’s check how they are different from each other.

  • ASP.NET uses .NET languages such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL). ASP uses VBScript. ASP code is interpreted during the execution.
  • ASP.NET which is developed by Microsoft is used to create dynamic web applications while ASP is Microsoft’s server-side technology used to create web pages.
  • ASP.NET is fully object-oriented but ASP is partially object-oriented.
  • ASP.NET has full XML Support for easy data exchange whereas ASP has no built-in support for XML.
  • ASP.NET uses the ADO.NET technology to connect and work with databases. ASP uses ADO technology.

10. Explain the different types of assembly.

Assemblies are classified into 2 types. They are:

Private Assembly:

  • It is accessible only to the application.
  • We need to copy this private assembly, separately in all application folders where we want to use that assembly. Without copying, we cannot access the private assembly.
  • It requires to be installed in the installation directory of the application.

Shared or Public Assembly:

  • It can be shared by multiple applications.
  • Public assembly does not require copying separately into all application folders. Only one copy of public assembly is required at the system level, we can use the same copy by multiple applications.
  • It is installed in the Global Assembly Cache(GAC).

11. What is a garbage collector?

Garbage collector frees the unused code objects in the memory. The memory heap is partitioned into 3 generations:

  • Generation 0: It holds short-lived objects.
  • Generation 1: It stores medium-lived objects.
  • Generation 2: This is for long-lived objects.

Collection of garbage refers to checking for objects in the generations of the managed heap that are no longer being used by the application. It also performs the necessary operations to reclaim their memory. The garbage collector must perform a collection in order to free some memory space.

During the garbage collection process:

  • The list of live objects is recognized.
  • References are updated for the compacted objects.
  • The memory space occupied by dead objects is recollected. The remaining objects are moved to an older segment.

System.GC.Collect() method is used to perform garbage collection in .NET.

12. What is caching?

Caching means storing the data temporarily in the memory so that the data can be easily accessed from the memory by an application instead of searching for it in the original location. It increases the speed and performance efficiency of an application.

There are three types of caching:

  • Page caching
  • Data caching
  • Fragment caching

13. Explain MVC.

MVC stands for Model View Controller. It is an architecture to build .NET applications. Following are three main logical components of MVC: the model, the view, and the controller.

Components of MVC

Model: They hold data and its related logic. It handles the object storage and retrieval from the databases for an application. For example:
A Controller object will retrieve the employee information from the database.
It manipulates employee data and sends back to the database or uses it to render the same data.

View: View handles the UI part of an application. They get the information from the models for their display. For example, any employee view will include many components like text boxes, dropdowns, etc.

Controller: They handle the user interactions, figure out the responses for the user input and also render the final output. For instance, the Employee controller will handle all the interactions and inputs from the Employee View and update the database using the Employee Model.

14. What is a delegate in .NET?

A delegate is a .NET object which defines a method signature and it can pass a function as a parameter.

Delegate always points to a method that matches its specific signature. Users can encapsulate the reference of a method in a delegate object.

When we pass the delegate object in a program, it will call the referenced method. To create a custom event in a class, we can make use of delegate.

15. What is boxing and unboxing in .NET?

Boxing is the process of converting a value type into a reference type directly. Boxing is implicit.

Unboxing is the process where reference type is converted back into a value type. Unboxing is explicit.

An example is given below to demonstrate boxing and unboxing operations:

int a = 10;      // a value type
object o = a;     // boxing
int b = (int)o;   // unboxing

16. What is the use of manifest in the .NET framework?

Manifest stores the metadata of the assembly. It contains metadata which is required for many things as given below:

  • Assembly version information.
  • Scope checking of the assembly.
  • Reference validation to classes.
  • Security identification.

17. What is the meaning of CAS in .NET?

Code Access Security(CAS) is necessary to prevent unauthorized access to programs and resources in the runtime. It is designed to solve the issues faced when obtaining code from external sources, which may contain bugs and vulnerabilities that make the user’s system vulnerable.

CAS gives limited access to code to perform only certain operations instead of providing all at a given point in time. CAS constructs a part of the native .NET security architecture.

18. What is the difference between an abstract class and an interface?

The main difference between an abstract class and an interface are listed below:

Abstract Class Interface
Used to declare properties, events, methods, and fields as well. Fields cannot be declared using interfaces.
Provides the partial implementation of functionalities that must be implemented by inheriting classes. Used to declare the behavior of an implementing class.
Different kinds of access modifiers like private, public, protected, etc. are supported. Only public access modifier is supported.
It can contain static members. It does not contain static members.
Multiple inheritances cannot be achieved. Multiple inheritances are achieved.

19. What are the types of memories supported in the .NET framework?

Two types of memories are present in .NET. They are:

Stack: Stack is a stored-value type that keeps track of each executing thread and its location. It is used for static memory allocation.

Heap: Heap is a stored reference type that keeps track of the more precise objects or data. It is used for dynamic memory allocation.

20. Explain localization and globalization.

Localization is the process of customizing our application to behave as per the current culture and locale.

Globalization is the process of designing the application so that it can be used by users from across the globe by supporting multiple languages.

21. What are the parameters that control the connection pooling behaviors?

There are 4 parameters that control the connection pooling behaviors. They are:

  • Connect Timeout
  • Min Pool Size
  • Max Pool Size
  • Pooling

22. What are MDI and SDI?

MDI (Multiple Document Interface): An MDI allows you to open multiple windows, it will have one parent window and as many child windows. The components are shared from the parent window like toolbar, menubar, etc.

SDI (Single Document Interface): SDI opens each document in a separate window. Each window has its own components like a toolbar, menubar, etc. Therefore it is not constrained to the parent window.

23. Explain the different parts of an Assembly.

The different parts of an assembly are:

  • Manifest – It holds the information about the version of an assembly. It is also known as assembly metadata.
  • Type Metadata – It consists of binary information of the program.
  • MSIL – Microsoft Intermediate Language code.
  • Resources – List of related files.

.NET Interview Questions For Experienced

24. What is an EXE and a DLL?

EXE and DLLs are assembly executable modules.

EXE is an executable file that runs the application for which it is designed. An EXE is produced when we build an application. Therefore the assemblies are loaded directly when we run an EXE. However, an EXE cannot be shared with the other applications.

Dynamic Link Library (DLL) is a library that consists of code that needs to be hidden. The code is encapsulated inside this library. An application can consist of many DLLs which can be shared with the other programs and applications.

25. Explain role-based security in .NET

Role-based security is used to implement security measures in .NET, based on the roles assigned to the users in the organization. In the organization, authorization of users is done based on their roles.

For example, windows have role-based access like administrators, users, and guests.

26. What is the order of the events in a page life cycle?

There are eight events as given below that take place in an order to successfully render a page:

  • Page_PreInit
  • Page_Init
  • Page_InitComplete
  • Page_PreLoad
  • Page_Load
  • Page_LoadComplete
  • Page_PreRender
  • Render

27. Can we apply themes to ASP.NET applications?

Yes. By modifying the following code in the web.config file, we can apply themes to ASP.NET applications:

       <pages theme="windows"/>

28. What is cross-page posting?

Whenever we click on a submit button on a webpage, the data is stored on the same page. But if the data is stored on a different page and linked to the current one, then it is known as a cross-page posting. Cross-page posting is achieved by POSTBACKURL property.

To get the values that are posted on this page to which the page has been posted, the FindControl method can be used.

29. What are security controls available on ASP.NET?

Following are the five security controls available on ASP.NET:

  • <asp: Login> Provides a login capability that enables the users to enter their credentials with ID and password fields.
  • <asp: LoginName> Used to display the user name who has logged-in.
  • <asp: LoginView> Provides a variety of views depending on the template that has been selected.
  • <asp: LoginStatus> Used to check whether the user is authenticated or not.
  • <asp: PasswordRecovery> Sends an email to a user while resetting the password.

30. What is MIME in .NET?

MIME stands for Multipurpose Internet Mail Extensions. It is the extension of the e-mail protocol which lets users use the protocol to exchange files over emails easily.

Servers insert the MIME header at the beginning of the web transmission to denote that it is a MIME transaction.

Then the clients use this header to select an appropriate ‘player’ for the type of data that the header indicates. Some of these players are built into the web browser.

31. Explain different types of cookies available in ASP.NET?

Two types of cookies are available in ASP.NET. They are:

  • Session Cookie: It resides on the client machine for a single session and is valid until the user logs out.
  • Persistent Cookie: It resides on the user machine for a period specified for its expiry. It may be an hour, a day, a month, or never.

32. What is the appSettings section in the web.config file?

https://www.interviewbit.com/blog/dot-net-developer/We can use the appSettings block in the web.config file, if we want to set the user-defined values for the whole application. Example code given below will make use of ConnectionString for the database connection throughout the project:

           <add key= "ConnectionString" value="server=local; pwd=password; database=default"  />


The scope of .NET is wide. It is a full-stack framework used to build entire large enterprise-scale and scalable software applications. .NET is fast, flexible, modern, and friendly and goes along well with other technologies which is why it is very popular among software developers.

Check out our career guide for a .Net Developer.

.net MCQs


int keyword refers to which .NET type?


Boxing allows the user to convert what?


An Event has ____ as the default return type.


If the exception does not occur, will the final block get executed?


If a variable is declared inside a method, then it is called as _______


Runtime environment provided by .NET is called as _______


In which file .Net assembly’s metadata is stored?


Common Type System (CTS) can manage _______


Specify root namespace used for fundamental types in .Net framework.


Which method is used to force garbage collection to run?


What is the functionality of Response.Output.Write()?