Important .NET Interview Questions And Answers

Question 1: What is meant by CLR?

CLR is a runtime provided by .NET. It allows us to execute the program on the .Net platform. The CLR provides "Simple Application Performance ,Safety, Multiple Language Support, Good Performance, etc".

Question 2: What is meant by ASP.NET?

ASP.NET is open source server-side web application framework designed for web development to produce dynamic web pages.

Question 3: What is the difference between STORED PROCEDURES and FUNCTIONS?


FunctionStores Procedures
It supports only Input Parameters.It supports both Input and Output
We can write any T-Sql statements which will not modify the existing Data-Base. We can write any T-Sql statements.ex: .dml,.dql,.ddl
We can call Functions using Select statement. using Select Statement.We can not call Stored Procedures
Functions can be call from Stored Procedures.Stored Procedures can not call from Fumctions.

Question 4: What is the difference between ABSTRACT CLASS and INTERFACE?


Abstract ClassInterface
It have Constants,Members with out Method Body.It has only Constants without
Method Body.
We can use any Access Modifiers for Visibilty [Public,Private,Internal,Protected].The methods of an Interface must be Public only.
Abstarct contains Constructors.Interface does not contain Constructors.

Question 5:What is the difference between AS and IS keywords?


Is Operator is used to Check the Compatibility of an Object with a given Type and it returns the result as a Boolean (True Or False).
As Operator is used for Casting Object to a given type Or Class.

Question 6:What is the difference between QUEUE and STACK?


A Stack is a Last-In First-Out (LIFO) container.A Queue is a First-In First-Out (FIFO)
Stack is a collection of items.Queue is an ordered collection of

Question 7: What is the difference between a STRUCT and a CLASS?


Structs are value types.Classes are reference types.
Structs cannot support inheritance. Classes can support inheritance
Structs are passed by value (like integers).Classes are reference (pointer) types.

Question 8: What do you mean by AUTHENTICATION and AUTHORIZATION?

Answer: Authentication is the process of validating a user on the credentials (username and password) and Authorization performs after Authentication. After Authentication a user will be verified for performing the various tasks, access is limited and it is known as Authorization.

Question 9: What is the global assembly cache (GAC)?

Answer: GAC is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC solves some of the problems associated with dll’s (DLL Hell).

Question 10: What is Boxing/Unboxing?

Answer: Boxing is used to convert value types to object.


  1. int x = 1;   
  2. object obj = x ;   
Unboxing is used to convert the object back to the value type.

  1. int y = (int)obj;  
Note: Conversion of Boxing and UnBoxing reduces Application Performance.

Question 11: What is garbage collection?

Answer: Garbage collection is the process of managing the allocation and release of memory in your applications.

NOTE: We can also call Garbage Collection Explicitly.

Question 12: What is meant by overloading and overriding?

Answer: Overloading is when you have multiple methods, with the same name but different signatures. Overriding is a principle that allows you to change the functionality of a method in a child class.

Question 13: How to find the 2nd Highest salary using Query?


Method 1: 
  1. select * from employees emp1 where 1 = (select count(DISTINCT(emp2.salary)) from employees emp2 where emp2.salary > emp1.salary)  
Method 2:

select top 2 salary from employees emp order by sal desc

Question 14: Write a program to print * ?

* *
* * *
* * * *

  1. Static void main(string[] Args)  
  2. {  
  3.     int num = 1;  
  4.     for (int i = 0; i < 4; i++)  
  5.     {  
  6.         for (int j = 0; j < num; j++)  
  7.         {  
  8.             console.write("*");  
  9.         }  
  10.         num++;  
  11.         console.writeline();  
  12.     }  
  13.     console.readline();  
  14. }  
Question 15: Explain ViewState?

Answer: It is a .NET mechanism to store the posted data among post backs. It allows the state of objects to be stored in a hidden field on the page, saved on client side and transported back to server whenever required.

Question 16: Difference between Response.Redirect and Server.Transfer?



A new request is generated from client-side for redirected page. It's a kind of additional round trip. As new request is generated from client, so the new URL is visible to user in browser after redirection.


A request is transferred from one page to another without making a round trip from client. For the end user, URL remains the same in browser even after transferring to another page.

Question 17: What are value types and reference types?

Value types are stored in the Stack whereas Reference types stored on heap.

Value Types: int,enum,byte,decimal,float,long.
Reference Types:String,class,interface,object.

Question 18: What is the difference between application exception and system exception?

Answer: The difference between application exception and system exception is that system exceptions are thrown by CLR and application exceptions are thrown by applications.

Question 19: What is the difference between Primary key and unique key?

Answer: Primary key does not allow the null values but unique key allows one null value.Primary key will create clustered index on column but unique key will create non-clustered index by default.

Question 20: What is difference between constants, read-only and, static?


Constants: The value can’t be changed.
Read-only: The value will be initialized only once from the constructor of the class.
Static: Value can be initialized once.

Question 21: What is the default timeout for a Cookie?

Answer: The default time duration for a Cookie is 30 minutes.

Question 22: What is a Cookie? Where is it used in ASP.NET?

Answer: Cookie is a lightweight executable program, which the server posts to client machines. Cookies store the identity of a user at the first visit of the Web site and validate them later on the next visits for their authenticity. The values of a cookie can be transferred between the user's request and the server's response.

Question 23: How many types of Cookies are available in ASP.NET?

There are two types of Cookies available in ASP.NET,
  • Session Cookie: Resides on the client machine for a single session until the user does not log out. 
  • Persistent Cookie: Resides on a user's machine for a period specified for its expiry, such as 10 days, one month, and never.  27)What is the use of the Global.asax file?
The Global.asax file executes application-level events and sets application-level variables.

Question 24: What events are fired when a page loads?

The following events fire when a page loads,
  • Page_Init() - Fires when the page is initializing. 
  • Page_LoadViewState() - Fires when the view state is loading. 
  • Page_LoadPostData() - Fires when the postback data is processing. 
  • Page_Load() - Fires when the page is loading. 
  • Page_PreRender() - Fires at the brief moment before the page is displayed to the user as HTML. 
  • Page_Unload() - Fires when the page is destroying the instances of server controls. 
Question 25: What is meant by Cursor in C-Sharp?

Answer: Cursor is a icon and it displays when a user move a mouse, trackball or a pen. It can be manage in C# by
Cursors class . It is present System.Windows.Forms namespace.

C# Code:

button1.Cursor = Cursors.Hand;
listBox1.Cursor =Cursors.No;

Creating a Cursor: Cursor is not a typical Windows Forms control. It is used as a helper control and does not have a user interface or design view. The Cursor class represents a cursor and it is created either using the Cursors class or load a cursor from a file. The following code snippet creates a cursor.

Cursor cur = Cursors.WaitCursor;
this.Cursor = cur;

Question 26: What is meant by COLLECTIONS in C-Sharp?

Answer: Collection classes are normally used to hold collections of values or objects in memory. In collection classes, elements are inserted using either the Add orInsert method, and deleted using the RemoveAt method. Finally, collections can be iterated over using the foreach statement.

  1. ArrayList
  2. HashTable
  3. SortedList
  4. BitArray
  5. Queue
Question 27: What are the various types of Authentication?

Answer: There are 3 types of Authentication namely Windows, Forms and Passport Authentication: 
  • Windows authentication: It uses the security features integrated in Windows NT and Windows XP OS to authenticate and authorize Web application users.

  • Forms authentication: It allows you to create your own list of users and validate their identity when they visit the Web site.

  • Passport authentication: It uses the Microsoft centralized authentication provider to identify users. Passport allows users to use a single identity across multiple Web applications.

Question 28: What are the various session state management options provided by ASP.NET?

Answer: ASP.NET provides two session state management: 

  • In-Process state management: In-Process stores the session in memory on the web server.

  • Out-of-Process state management: Out-of-Process stores data in an external data source. This data source may be a SQL Server or a State Server service. 

Question 29: What are the validation controls available in ASP.NET?

Answer: ASP.NET validation controls are the following:

  • RequiredFieldValidator: This validates controls if controls contain data.
  • CompareValidator: This allows checking if data of one control match with other control.
  • RangeValidator: This verifies if entered data is between two values.
  • RegularExpressionValidator: This checks if entered data matches a specific format.
  • CustomValidator: Validate the data entered using a client-side script or a server-side code.
  • ValidationSummary: This allows developer to display errors in one place.
You can enhance your knowledge more, by reading the following articles.

Up Next
    Ebook Download
    View all
    View all