Buy our 600+ interview questions videos package


.NET interview questions: - If we want to update interface with new methods, what is the best practice?

The biggest use of interface is to ensure that strict CONTRACT is followed between clients and components. So that when changes happen on the components clients do not have to change too much.  In real world CONTRACTS between two parties do not change which implies that interfaces should also not change.

So if you want to add new methods or change methods in interfaces the best practice is to create new interfaces by inheriting. With this approach your older client who are using the interface stay happy and the new clients who want those new or changed methods get the benefits of the new functionality.

Let’s consider you have a simple interface called as “IView” which helps you to view data , below is the code for the same. Let’s consider that this interface is consumed by many clients.


Over a period of time some users demand “Edit” functionality as well but the rest of the users are happy with the ‘View” functionality and they do not want them to get affected by these changes. Now if you go and change this interface ( “IView”) a.k.a you will be disturbing everyone.


                                     Figure: - update interface with new methods

So the best option would be to add a new interface i.e. “IEdit” which inherits from “IView”. So the “IEdit”  will have the functionality for “Edit” as well as “View” because it’s also inheriting from “IView”.  And the clients who are consuming “IView” do not need to update as “IView’ is not changed at all.


So putting this whole story in one single sentence for the interviewer.


See the following .NET interview questions video on Debug directive in C#:  -

WPF Interview Questions:- Can you explain the overall architecture of WPF?


                                                      Figure: - Architecture of WPF

Above figure shows the overall architecture of WPF. It has three major sections presentation core, presentation framework and milcore. In the same diagram we have shown how other section like direct and operating system interact with the system. So let’s go section by section to understand how every section works.

User32 :- It decides which goes where on the screen.

DirectX : - As said previously WPF uses directX internally. DirectX talks with drivers and renders the content.

Milcore : - Mil stands for media integration library. This section is a unmanaged code because it acts like a bridge between WPF managed and DirectX / User32 unmanaged API.

Presentation core :- This is a low level API exposed by WPF providing features for 2D , 3D , geometry etc.

Presentation framework :- This section has high level features like application controls , layouts . Content etc which helps you to build up your application.

Below video explain what is WPF and how they differ from Windows form

.NET interview questions: - Does code contract only do dynamic checks?

The best part of code contract is it also does static checking. Once you build the code the contract analysis check runs to see if any pre-conditions, post-conditions or invariants (runningconditions) are violated.


For instance you can see in the below figure how the error is shown in the error window list. The “Add” method is called with zero value and the code contract shows the error stating that this call is invalid in the IDE itself.


Above is the .NET interview questions and see following video on concurrent generic collections in C#:  -

ADO.NET interview questions: - What are the different components in ADO.NET?

There are 6 important components in ADO.NET:-

  • Connection: -This object creates a connection to the database. If you want to do any operation on the database you have to first create a connection object.
  • Command: -This object helps us to execute SQL queries against database. Using command object we can execute select, insert, update and delete SQL command.
  • Data reader: - This provides a recordset which can be browsed only in forward direction.It can only be read but not updated. Data reader is good for large number of records where you want to just browse quickly and display it.
  • Dataset object: -This provides a recordset which can be read back and in forward direction. The recordset can also be updated. Dataset is like a in memory database with tables, rows and fields.
  • Data Adapter: -This object acts as a bridge between database and dataset; it helps to load the dataset object.
  • Data View: - This object is used to sort and filter data in Data table of dataset.


                                                         Figure: - ADO.NET architecture


Also see following ADO.NET interview questions videos on dataset is a connected while datareader is disconnected:  -

Dec 6

ASP.NET MVC interview questions: - Differentiate between tempdata , viewdata and viewbag?


                 Figure: - difference between tempdata, viewdata and viewbag

Temp data: - Helps to maintain data when you move from one controller to other controller or from one action to other action. In other words when you redirect,“tempdata” helps to maintain data between those redirects. It internally uses session variables.

View data: - Helps to maintain data when you move from controller to view.

View Bag: - It’s a dynamic wrapper around view data. When you use “Viewbag” type casting is not required. It uses the dynamic keyword internally.


                                                              Figure: - dynamic keyword

Session variables: - By using session variables we can maintain data from any entity to any entity.

Hidden fields and HTML controls: - Helps to maintain data from UI to controller only. So you can send data from HTML controls or hidden fields to the controller using POST or GET HTTP methods.

Below is a summary table which shows different mechanism of persistence.


Above was the ASP.NET MVC interview questions see following one of architecture video on Lazy Loading Design Pattern:  -

Dec 2

.NET interview questions: - What are different access modifiers?

One of the basic but favorite .NET interview questions of interviewer.

There are 5 access modifiers. Access modifiers define scope for members.

  • Private: Accessible only with in the class.
  • Protected: -Accessible with in the class and in derived classes.
  • Friend (internal in C#):-Accessible anywhere within the current project.
  • Protected friend (protected internal in C#): - Accessible with current project and derived classes.
  • Public: -Accessible everywhere.


                                       Figure: - different access modifiers

Also see following .NET interview questions videos Circular dependency in C#:  -

.NET interview questions: - Distinguish between Reflection and Dynamic?

  • Both reflection and dynamic are used when we want to operate on an object during runtime.
  • Reflection is used to inspect meta-data of an object. It also has the ability to invoke members of an object on runtime.
  • Dynamic is a keyword which was introduced in .NET 4.0. It evaluates object calls during runtime. So until the method calls are made compiler is least bothered if those methods / properties etc exist or not. 
  • Dynamic uses reflection internally. It caches the method calls made thus improving performance to a certain extent.
  • Reflection can invoke both public and private members of an object while dynamic can only invoke public members.

Below is the detail comparison table which shows in which scenario they are suited.


Below is a simple diagram which summarizes visually what reflection can do and what dynamic keyword can do?


Also see following .NET interview questions videos on regular expressions & can we see some practical demonstrations:  -

.NET interview questions: - What are similarities and difference between Class and structure?

Similarities between Class and structure’s: -

Following are the similarities between classes and structures:-

  • Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers.
  • Structures and classes can implement interface.
  • Both of them can have constructors with and without parameter.
  • Both can have delegates and events.

Difference between Class and structure’s: -

Following are the key differences between them:-

  • Structures are value types and classes are reference types. So structures use stack and classes use heap.
  • Structures members cannot be declared as protected, but class members can be. You cannot do inheritance in structures.
  • Structures do not require constructors while classes require.
  • Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC.

Also see following .NET interview questions videos on about difference between Throw and Throw ex: -

Explain the difference between early binding and late binding? ( C# interview questions with answers)

Early binding or early bound means the target methods, properties and functions are detected and checked during compile time. If the method / function or property does not exist or has a data type issues then the compiler throws an exception during compile time.

Late binding is opposite of early binding. Methods, properties and functions are detected during runtime rather than compile time. So if the method, function or property does not exist during runtime application will throw an exception.

In simple words everything is early binded until you are using reflection or dynamic keyword.


.NET interview questions: - What is UML and which are the important diagrams?

This the .NET interview questions for 2+ years experience developer.

The Unified Modeling Language (UML) is a graphical language for visualizing, specifying, constructing, and documenting the artifacts of a software-intensive system.

UML provides blue prints for business process, System function, programming language statements, database schemas and reusable components. Some of the important UML diagrams  are use case , class diagrams , sequence diagram,  activity diagram , object diagrams , collaboration diagrams ,  state chart diagrams , component diagram  and deployment diagram.

Also see following .NET interview questions video on UML(Unified Modeling Language)

ASP.NET interview questions: - When to use what? - “Server.Transfer” or “Response.Redirect”

Use “Server.Transfer” when you want to navigate pages which resides on the same server , use ‘Response.Redirect’ when you want to navigate between pages which resides on different server.


Response.Redirect(URL,true) vs Response.Redirect(URL,false) ?


Response.Redirect(URL,false) :- Client is redirected to a new page and the current page on the server will keep processing ahead.

Response.Redirect(URL,true) :- Client is redirected to a new page but the processing of the current page is aborted.

Also see following ASP.NET interview questions video on importance of session and viewstate  

Nov 5

When should we use “x:name” vs “name” ? (C# WPF interview questions)

There is no difference between “x:name” and “name” , “name” is short hand of “x:name”.  But in classes where you do not find “name” property ( this is a rare situations) we need to use “x:name” property.

Below video explain what is WPF and how they differ from Windows form

ADO.NET interview questions: - Explain in detail the fundamental of connection pooling?

When a connection is opened first time, a connection pool is created and is based on the exact match of the connection string given to create the connection object. Connection pooling only works if the connection string is the same. If the connection string is different, then a new connection will be opened, and connection pooling will not be used.

Let us try to explain the same pictorially. In the above figure, you can see there are three requests “Request1”, “Request2”, and “Request3”.  “Request1” and “Request3” have same connection string so no new connection object is created for “Request3” as the connection string is same. They share the same object “ConObject1”. However, new object “ConObject2” is created for “Request2” as the connection string is different.


This question is taken from .NET interview questions book

Also see following video on ADO.NET interview questions on dataset and datareader: -

ASP.NET interview questions: - Which are the various modes of storing ASP.NET session?

  • InProc: - In this mode Session, state is stored in the memory space of the Aspnet_wp.exe process. This is the default setting. If the IIS reboots or web application restarts then session state is lost.
  • StateServer:-In this mode Session state is serialized and stored in a separate process (Aspnet_state.exe); therefore, the state can be stored on a separate computer(a state server).
  • SQL SERVER: - In this mode Session, state is serialized and stored in a SQL Server database.

Session state can be specified in <sessionState> element of application configuration file. Using State Server and SQL SERVER session state can be shared across web farms but note this comes at speed cost as ASP.NET needs to serialize and deserialize data over network repeatedly.

See the below ASP.NET interview questions video on ASP.NET Masterpages

What is Multi Targeting in .NET? (Visual studio.NET Interview questions with answers)

In previous versions of Visual studio, every version was tied up with a framework. For instance VS 2003 only works with 1.1 and VS 2005 only work with 2.0.

From VS 2008 they have added multi-targeting feature. You can use same visual studio with different versions of .NET framework. So if you click on project properties you can now change the framework version to different types and check if your code is compatible with old version.