.NET Framework Exclusive Interview Questions and Answers (46) - Page 2

  • A joint initiative from DotNetFunda.Com and Questpond.
  • A one stop place on the internet to get trusted and proven Interview Questions (based on more than a decade of experience in this field) to ensure the success of the candidates.
  • You will find almost all Interview questions from Questpond here and this list is growing day by day with all latest and updated interview questions.

46 records found.

Get 650+ Questpond's Interview videos on discount

ASP.NET and .NET Interview question video :- What is Authentication and Authorization ?

Authentication is the process where we identify who the user is.
Authorization is the process where we check what kind of role the identified user has.

Below is a simple video which describes these two vocabularies in a precise manner.

.NET Interview questions :- How did you do unit testing in your project?

In today’s software industry people do not just look how good you are in coding but they would like to know how good you are in processes.

This C# interview question touches one of the important aspects of SDLC processes which is “Unit testing” or you can say white box testing.

Note: - Many developers answer that they did unit testing manually. Many interviewers of bigger companies will not be pleased with this answer. The whole point about unit testing is to automate white box testing. The time you say you have done manual testing which means you have done integration testing.

There are two important testing tools which are widely used to do unit test in Microsoft technologies, first is VSTS Unit test and second is NUNIT. So if you have used one of these tools, do talk about the same. Below is a simple sample answer by a developer who has used VSTS unit test for testing.

“Our project was divided in three layers UI, BO and Data access layer. As a developer I was responsible to write unit test code on the middle layer or the business object. We used VSTS unit test suite to write our test. So for each important functions and methods of the middle layer stubs where generated   by right clicking on the middle layer functions. Inside the stub we went and put proper assert function as needed by the test”.


.NET and SQL Server interview question: - What is difference between truncate and delete?

Both Truncate and Delete are used to delete data from the tables.  Below are some important differences.

·     TRUNCATE is a DDL (data definition language) statment whereas DELETE is a DML (data manipulation language) statement.

  • In DELETE command we can use where condition in TRUNCATE you cannot.

  • TRUNCATED data cannot be rolled back while delete can be.

  • When there are triggers on table and when you fire truncate trigger do not fire . When you fire delete command triggers are executed.

  • TRUNCATE resets the identity counter value where DELETE does not.

  • Delete and Truncate both are logged operation. Delete operation is logged on row basis while TRNCATE logs at page level.

  • TRUNCATE is faster than DELETE.



.NET and Java J2ee design pattern interview question :-What is the difference between Object and class adapters?

Below are the main difference between these 2 patterns.

Object adapter
Can adapt classes as well as sub classes since uses composition
More flexible since dynamic polymorphism can be used with composition

Class adapter

Can adapt classes or sub classes not both. As a result no need to re implement the entire adaptee
More efficient since class adapter acts as adapter and adaptee


.NET and Java J2ee Design pattern interview question :- What is the difference between Decorator and Adapter pattern?

Below is the main difference between these two design patterns.

Decorator Design pattern

Used to deal with new behavior or responsibilities without affecting existing code.
Provides a wrapper over objects to apply same method which yields different results based on whether the object invoked is granular or composite.
Change of interface does not happen.
Adapter Design pattern

Mainly involved in converting interfaces as per the requirement of client
Allows use of new libraries without changing existing methods
Change of interface happens in this case


.NET interview questions :- What are Regex / regular expressions ?

Regex or regular expression helps us describe complex patterns in texts. Once you have described these patterns you can use them to do searching, replacing, extracting and modifying text data.

Below is a simple sample of regex. The first step is to import the namespace for regular expressions.

using System.Text.RegularExpressions;


The next thing is to create the regex object with the pattern. The below pattern specifies to search for alphabets between a-z with 10 length.

Regex obj = new Regex(“[a-z]{10}”);


Finally search the pattern over the data to see if there are matches. In case the pattern is matching the ‘IsMatch’ will return true.



Design pattern interview questions :- Which design patterns have you used in your project ?

First thing what ever you say , for heaven sake do not say we had used all design patterns ;-) . Look at your project and see which design pattern have you used. Almost all projects use design patterns knowingly or unknowingly , until the project is complete disorganized.

While explaining do ensure to make a 1 line comment atleast to say why that design pattern was used.

Below goes a decent answer of explaining things collectively. Please note answer will change as per your project implementation. 

In my current project we had used MVC, Singleton, factory , iterator   and template pattern.

My project was tier architecture, divided in to 3 main sections, UI, Business layer and data access layer.

At the presentation level we had used MVC pattern, so the UI and model was separated using controller class.  

To share common data across all tiers we had used the singleton pattern.

Factory classes where used between each layer for decoupling and centralizing object creation to avoid code complication.

Iterator pattern was used to browse through middle tier objects thus providing a tight encapsulation.

The   middle tier objects and their child objects where standardized using template pattern for consistent vocabulary and naming convention for business objects.

Watch the below design pattern video which explains factory pattern.


.NET interview questions :- What is the difference between class and structures ?

1. Classes are reference types and structs are value types. So in other words class will be allocated on a heap and structs will be allocted on the stack.

2. You cannot have instance Field initializers in structs. Example


class MyClass1
int myVar =10; // no syntax error.
public void MyFun(
// statements


struct MyStruct1
int myVar = 10; // syntax error.
public void MyFun(
// statements

3. Classes can have explicit parameterless constructors. But structs cannot have

4. Classes must be instantiated using the new operator. But structs can be

5. Classes support inheritance.But there is no inheritance for structs.( structs don’t support inheritance polymorphism )

6. Since struct does not support inheritance, access modifier of a member of a struct cannot be protected or protected internal.11. A class is permitted to declare a destructor.But a struct is not

7. classes are used for complex and large set data. structs are for simple data structures.


.NET and Java J2ee Design pattern interview question: - What is the difference between Template and Strategy pattern

Below are the main differences between these two design patterns: -

Template Design pattern

Defines outline for algorithms and allows sub class to override some steps.
Efficient in terms of less redundant code.
Depends on super class for methods.

Strategy Design pattern

Uses object composition to provide variety of algorithm implementation.
Flexible in terms of allowing users to change algorithm at run time.
All the algorithms can be itself implemented.


.NET interview questions: - What are the different principle of OOPS?

Different principles of OOPS are Abstraction, Encapsulation, Polymorphism and Inheritance.

1. Abstraction:- It is a thought process which show only the necessary properties.

2. Encapsulation:- Hiding complexity of a class.

3. Inheritance:- Defining a Parent-Child Relationship.

4. Polymorphism:- Object Changes it's behaviour according to the situation.


.NET interview questions: - What is public, private, protected, internal and internal protected?

In the following manner we can describe the C# access modifiers: -

public - The members (Functions & Variables) declared as public can be accessed from anywhere.

private - Private members cannot be accessed from outside the class. This is the default access specifier for a member, i.e if you do not specify an access specifier for a member (variable or function), it will be  considered as private. Therefore, string PhoneNumber; is equivalent to private string PhoneNumber;

protected - Protected members can be accessed only from the child classes.

internal - it can be accessed only within the same assembly.

internal Protected - internal protected can be accessed within the same assembly as well as in derived class.


.NET and C# interview question - What are the various questions asked in C# and .NET interview?

The following are the 4 basics section for the interview purpose and below is the diagram to understand in better manner.

  • .NET basics
  • New Technologies
  • Architecture
  • Process

.NET basics include the questions on the following sections.

  • Basics of .NET
  • OOPS

  • SQL Server
  • Web Services

New Technologies includes the questions on the following sections.

  • WCF
  • WPF/Silverlight
  • LINQ/Entity framework
  • Azure
  • WWF

Architecture includes the questions on the following sections.

  • Design Patterns
  • UML
  • Documentation
  • Requirement to design

Process includes the questions on the following sections.

  • Agile Estimation
  • FPA
  • CMMI
  • Six Sigma

.NET basics

Following questions are related to fundamentals of .NET.

  • What is CLR, CTS, CTS, IL Code?
  • What is Value type, Reference type and Stack, Heap Memory?
  • What is Garbage Collector and working of Garbage Collector?
  • What are GAC, Delegate, Event, and JIT?

Following questions are related to object oriented programming system (OOPS).

  • Why we need OOPS concept?
  • What are the different Principals of OOPS?
  • How to implement Abstraction, Encapsulation, Inheritance and Polymorphism?
  • What are Abstract Class and Interface and differences? What are the Classes and Object?

Following questionsis related toSQL Server.

  • What are SQL Queries, Sub Queries?
  • What are Joins and its different types?
  • What are Normalization, Denormalization and Performance Tuning?
  • What are Indexes, Clustered Indexes?

Following questions is related to ADO.NET.

  • What are Dataset, Data Reader and Data Adapter?
  • What are Connection Object and Connection String?

Following questions is related to ASP.NET.

  • What are the Session Variable, Application and Cache Object?
  • What isServer.Transfer and Response.Redirect?
  • Difference between Server.Transfer and Response.Redirect?
  • What is Authentication and Authorization?

Following questions is related to Web Services.

  • What is WSDL?
  • What are ASMX, SOAP?

New Technologies

Following questions is related to WCF.

  • What are Operation Contract, Service Contract and Data Contract?
  • What is Data Member?
  • What are Address Binding and Contract Binding?
  • What do you mean End points?

Following questions is related toWPF/Silverlight.

  • What are XAML, XAP?
  • What is Silverlight Architecture?
  • What is MVVM pattern and RIA Services.

Following questions is related toLINQ/Entity framework.

  • What are the three main components on LINQ?
  • What is the use LINQ and Entity Framework?
  • What are Data Context Object and Entity Object?
  • What are LINQ DBML and LINQ EDMX?

Following questions is related toAzure.

  • What is Cloud Computing?
  • What are blobs, tables and Queues?

Following questions is related toWWF.

  • What areSequential Workflow and State Machine Workflow?


Following questions is related to Design Pattern.

  • What is Factory Design Pattern?
  • What areSingleton Design Pattern and Iterator?

Following questions is related to MVC, MVP and MVVM.

  • Define MVC, MVP and MVVM?
  • What is MVC template and when to use?

Following questions is related toUML.

  • What are Use cases?
  • What is Activity diagram and Class diagram?

Following questions is related toDocumentation.

  • What areRequirement document and Design document?
  • What is test plan?
Following questions is related toRequirement Design.

  • How will you go from Requirement to Design?


Following questions is related toAgile.

  • What are Scrum Backlog Template and Simple Backlog Template?

Following questions is related toEstimation FPA.

  • What are EI, EO, EQ and EIF?

Following questions is related toCMMI.

  • What is meant by Key Process Area (KPA)?
  • What are the different five level of CMMI?

Following questions is related toSix Sigma.

  • What is Six Sigma?
  • What is the importance’s of Six Sigma?
  • What are Six Sigma Yellow Belt and Black Belt?


.NET interview question - What is Shadowing?

Shadowing is a concept of altering the behaviour of the base class member. It basically replaces complete element of the parent class like method becomes a variable.

For example: In the below example in class1 'i' is declared as variable whereas in class2 'i' is declared as a method.

class Program

static void Main(string[] args)
class1 obj = new class1();
class2 obj1 = new class2();
obj1.i(); //here i is treated as method
Console.WriteLine(obj.i); //here i is treated as variable
class class1
public int i=2;
class class2 : class1
public void i()
Console.WriteLine("Hello World");


.NET and Java J2EE Design pattern interview question: - What is the difference between Facade and Mediator pattern?

Facade Design pattern

  1. Aims at simplifying interface.

  2. Existence of façade is not known to sub-system.

  3. Intermediates between client and sub stem.

Mediator Design pattern

  1. Aims at simplifying object interaction.

  2. Existence of mediator is known to objects since they interact using the same.

  3. Intermediates between various objects which want to interact.


.NET/ASP.NET interview Questions - How will you do code review using FxCop in .NET?

FxCop is a code analyzer tool which runs on .NET dll file it helps you to analyze the quality of .NET code. (Quality in terms of coding standards, best practices etc.)

To view how exactly the FxCop do code review you need to download the FxCop from MSDN site and install it on your local host machine.

As FxCop runs on .NET dll file you need to add the dll file of your project on which you want to do code review.
The below diagram will give you an idea of how will you add the dll file in FxCop.


Once you click on the Add Target button just browse to the dll file you want to do code review like below diagram.


After adding the dll file to FxCop, Now click on the Analze button and you will see the window like below diagram with the respective result.


Once you click on analyze button it runs all the rules on the selected dll file and shows that what kind of rules are broken by the dll file.As you see in the above diagram some of the rules are broken by the selected dll file.
You can take these rules and try to close your project structure in standard manner and improve the quality of your project.


.NET/ASP.NET Interview Question - How will you do Unit Testing using Nunit?

Unit testing is validation and verification technology where the developer tests the individual units of source code. These individual units can be functions, methods or class.

Below is the simple Math class which has a Add function with two input parameter. The Add function basically adds the number and gives the addition of these two numbers.

As a developer we would like to test is this Add function actually works properly or not .
namespace NunitTest
public class Math
public int Add(int i, int j)
int sum;
sum = i + j;
return sum;
In order to do unit testing by using Nunit the first thing you need to create a simple CheckNunit class as shown in the code below.
namespace CheckNunit
public class NunitTest
[Test]//it is called as attribute
public void check()
Math obj = new Math();
int result = obj.Add(10, 20);
Assert.AreEqual(30, result);
In NunitTest class the check function is attributed by the Test.it is saying that we are passing 10 and 20 value and we are expecting the result as 30.if the result is 30 then everything is working properly else there is something wrong in the code.

Once you have completed the above steps, Open Nunit software and select the .dll file of CheckNunit like the following diagrams.



Now click on run button and see the respective output. If it displays green color then everything is working fine and if it displays red color then there is something wrong in code. The following two diagram will give you an better idea.

N3.pngLet inject a small defect, so that we can check how Nunit display the result.
Now I change the Addition(+) sign as Multiplication(*) sign so the method fail to add values and Nunit displays Red signal like below diagram. 



.NET/ASP.NET Interview Question - How will you do Unit Testing using VSTS?

Unit testing is validation and verification technology where the developer tests the individual units of source code. These individual units can be functions, methods or class.

Below is the simple Math class which has a Add function with two input parameter. The Add function basically adds the number and gives the addition of these two numbers.

As a developer we would like to test is this Add function actually works properly or not.

namespace TestVSTS
public class Math
public int Add(int i, int j)
         int sum;
         sum = i + j;
         return sum;

In order to do unit testing by using VSTS the first thing you need to create a simple unit test. In visual studio team system (VSTS)they provide the test menu in which you can select the unit testing as you can see in the below diagrams.



After selecting unit test open the .cs file and write the logic in [TestMethod] attribute which you want to test.

public void Check()
      Math obj = new Math();
      int r = obj.Calculate(10,20);

Once you have completed the above steps, now set unit test project as startup project, and run the application.
If the function work properly it will gives us Passed result as you see in below diagram.


If the Unit test gives us Failed result it means something wrong in function as you see in the below diagram.



.NET and C# interview questions: How to view a .NET assembly?

When coming to understand the internals, nothing can beat ILDASM. ILDASM converts the whole ‘exe’ or ‘dll’ in to IL code. To run ILDASM you have to go to ‘C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin’. Note that we had v1.1 you have to probably change it depending on the type of framework version you have.

If you run IDASM.EXE from the path you will be popped with the IDASM exe program as shown in figure. Click on file and browse to the respective directory for the DLL whose assembly you want to view. After you select the DLL you will be popped with a tree view details of the DLL as shown in figure ILDASM. On double clicking on manifest, you will be able to view details of assembly, internal IL code etc as shown in the figure.

Note: - The version number are in the manifest itself which is defined with the DLL or EXE thus making deployment much easier as compared to COM where the information was stored in registry. Note the version information in Figure Manifest view.

You can expand the tree for detail information regarding the DLL like methods, properties, functions etc.

And once you open the Manifest you will be able to see the inner details as shown in the following picture: -

Following is the video which shows that how the questions are asked C# and .NET interviews.

C# and .NET interview questions: What is an interface?

Interface is a contract that defines the signature of the functionality. So if a class is implementing a interface it says to the outer world, that it provides specific behavior. Example if a class is implementing ‘Idisposable’ interface that means it has a functionality to release unmanaged resources. Now external objects using this class know that it has contract by which it can dispose unused unmanaged objects.

  • Single Class can implement multiple interfaces.
  • If a class implements a interface then it has to provide implementation to all its methods.

Following code shows that one has the interface definition and other class implements the interface. Below is the source code “IInterface” is the interface and “ClsDosomething” implements the “IInterface”. This sample just displays a simple message box.

Public Interface IInterFace

Sub Do Something ()
End Interface

Public Class ClsDoSomething
Implements IInterFace
Public Sub DoSomething () Implements WindowsInterFace.IInterFace.DoSomething
MsgBox (“Interface implemented”)
End Sub
End Class

After implementing the above code you will get the following output as shown:

Following you can see a simple video on boxing and unboxing:

.NET interview questions: - What are Tuples and when to use Tuples?

Tuple: - A tuple is a data structure that has a specific number and sequence
of elements. An example of a tuple is a data structure with three elements
(known as a 3-tuple or triple) that are used to store an identifier such as a
person's name in the first element, a year in the second element, and the
person's income for that year in the third element. The .NET Framework directly
supports tuples with one to seven elements. In addition, you can create tuples
of eight or more elements by nesting tuple objects in the Rest property of a
Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> object.

In simple words Tuple are nothing but they are objects which helps us to
logically group other kind of objects inside.

Let’s first see in what kind of scenario Tuple are applicable.

Suppose we have a simple string which has Customer’s, FirstName, MiddleName,
LastName and PhoneNumber like below code snippet.

string str = "Feroz S Shaikh 966457"; // Here you can see that the Customer's 

Name and Phone Number are Seperated by (‘ ’)spaces.

Now, you would like to parse the data and take the data in to individual
variables like below code snippet.

string strFirstName = "";//this variable will hold Customer FirstName.

string strMiddleName = "";//this variable will hold Customer MiddleName.
string strLastName = "";//this variable will hold Customer LastName.
double PhoneNumber = 0;//this variable will hold Customer PhoneNumber.

In order to parse data into individual variables, we have to create a function
with “Out” parameters and have to use “Split” function like below code snippet.

static void ParseData(string strData, out string strFirstName, out string strMiddleName, out string strLastName, out double PhoneNumber)

string[] ArrayData = new string[3];//Created Array with Size 3.
ArrayData = strData.Split(' ');//Used Split function to split the data.

strFirstName = ArrayData[0];//Passed the data to strFirstName.
strMiddleName = ArrayData[1];//Passed the data to strMiddleName.
strLastName = ArrayData[2];//Passed the data to strLastName.
PhoneNumber = Convert.ToDouble(ArrayData[3]);//Passed the data to PhoneNumber.

Still now we have done with parsing the data.

Now just invoke this function from the main class like below code snippet.

ParseData(str, out strFirstName, out strMiddleName, out strLastName, out PhoneNumber);

Now, let just display the result for that just add the below code snippet.

Console.WriteLine("FirstName :" + strFirstName);

Console.WriteLine("MiddleName : " + strMiddleName);
Console.WriteLine("LastName : " + strLastName);
Console.WriteLine("PhoneNumber : " + PhoneNumber.ToString());

Let’s see how the result set look like.

Now, the above code is nice its work’s properly but the concern here is the code
tidiness, in current scenario all the variables are individual variables in case
if you want to parse the data around it would be very tedious job to do and it
would make your very lengthy and not be very easy to read.

The solution for the above code is that if you can club the individual variables
all together in to an object and use that object to pass the data anywhere you
want to that would bring down our code to a great extent.

So Tuples help us out to achieve the above and make our code more readable and

Let’s see how exactly help us to achieve the above, to do that follow the
following steps.

Step1: - create a new project Console Application for that Go To > New > File
> Project > Windows > Select Console Application.

Step2: - create a string variable containing data like below code snippet.

string str = "Feroz S Shaikh 966457";

Step3: - creating tuple like below code snippet.

static Tuple<string, string, string, double> ParseData(string strData) //

created tuple with three string data type and one double type.

string[] ArrayData = new string[3];//Created Array with Size 3.
ArrayData = strData.Split(' ');//Used Split function to split the data.
//assigned the data to the tuple object.
return Tuple.Create<string, string, string, double>

Step4: - Now receive the tuple in the main class like below code snippet and

var CustomerInformation = ParseData(str);//recieved the tuple.

//assigned the tuple data.
Console.WriteLine("FirstName :" + CustomerInformation.Item1);
Console.WriteLine("MiddleName : " + CustomerInformation.Item2);
Console.WriteLine("LastName : " + CustomerInformation.Item3);
Console.WriteLine("PhoneNumber : " + CustomerInformation.Item4);

In the above code snippet as soon as you click CustomerInformation(.)(dot) the
VS business intelligence will show like below diagram.

Now just run your application and will see the result like below diagram.

Also view following video on why anonymous types are better than tuples.

More .NET FRAMEWORK Interview Questions & Answers here

Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Exclusive Interview Questions and Answers Categories