Buy our 600+ interview questions videos package

Apr 9

.NET interview questions: - What is Assembly and Namespace? What are the different types of Assembly? State differences between them?

 Following is .NET interview questions on Assembly and Namespace in .NET.

Assembly: -

Assembly is unit of deployment like EXE or a DLL.

Namespace: -

  • It  logically groupsclasses, for instance System.Web.UI logically groups UI related features like textboxes, list control etc.
  • In Object Oriented world, many times it is possible that programmers will use the same class name. Qualifying NameSpace with class names avoids this collision.

Different types of Assembly: -

There are two types of assembly Private and Public assembly. A private assembly is normally used by a single application, and is stored in the application’s directory, or a sub-directory beneath. A shared assembly is stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime.

Shared assemblies are needed when we want the same assembly to be shared by various applications in the same computer.

Difference between NameSpace and Assembly: -

Following are the differences between namespace and assembly:

  • Assembly is physical grouping of logical units, Namespace, logically groupsclasses.
  • Namespace can span multiple assemblies while assembly is a physical unit like EXE, DLL etc.
Apr 4

.NET interview questions: - What are similarities and difference between Class and structure? When to use Class or structure?

One of the common .NET interview questions asked during .NET interview: -

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.

When to use Structures or Classes: -

You will use structures when:-

Point 1:- If you want to represent a custom value type. This custom value type is derived from primitive data types (int, double). Some of the example’s of custom types are co-ordinates (which have X, Y), complex numbers (which have real and imaginary components).  You can also term these things as value objects or technical objects. Technical objects do not represent real world objects like customer, supplier, invoice etc.

Point 2:- If you want to have low memory foot print. For instance let’s say you want to plot a graph. To plot a graph you need to have 100’s of objects created so that you can represent co-ordinates.  Now if you create a class and generate those 100’s of objects you end up putting lot of load on your garbage collector. If you create a “struct”, it’s a value type. So they get created and destroyed immediately. Thus putting less load on memory.
For all other scenarios use a class.

ASP.NET interview questions: - Can you explain master pages concept in ASP.NET and how do you create master pages?

Master pages are templates which can be applied to your web pages to bring in consistent look and feel and uniform structure. By creating templates we also avoid lot of duplication of code across web pages.

For example let’s say you want all your web pages in your application to have left menu, banner and footer (Refer figure Master page concept). So you can create a template and then apply that template to your webpages.


Creating Master Pages: -

To create a master page you can use the “master page” template from visual studio as shown in the below figure. In order to apply the master template we can use “Web form using master page” template.



In the master page you can define place holder using “ContentPlaceHolder” control. This is the place where your ASP.NET pages will be plug in their data.


Once master page template is created with necessary place holders you can then later in the web pages use the “MasterPageFile” to refer the template and you can use the content place holder to plug data.

For instance you can see the below code snippet of a page which uses master pages. You can also see how the “ContentPlaceHolder1” is used to place a simple text data “Company was established in 1990”.


Also see the following ASP.NET interview questions video on ASP.NET Masterpages: -

.NET interview questions : - What is a delegate and how can we create a delegate? What is a multicast delegate?

Delegate is an abstract pointer to a function or method.  In other words you can create a pointer which points to a method or function and then pass that pointer wherever you wish and invoke the function / method.

Creation of a delegate

Creating a delegate is four step process:-

  • Declare a delegate.
  • Create an object reference.
  • Point the reference to the method.
  • Invoke the method via the delegate.

Below is the code snippet for the same.

   // Declare a delegate
   public delegate int PointToAdd(int i, int y);

   // Create a reference pointer
   PointToAdd objpointer = null;

   // Point to the method
   objpointer = Add;

   // Invoke the function/method

What is a multicast delegate?

Normally when you create a delegate, your delegate points to only one function or method. In case you want to point multiple functions and invoke them sequentially, you need to use the multicast delegate.

To point to multiple function using delegate pointer we need to use “+=” sign as shown in the below code snippet.

    ptrcall += Method1;
    ptrcall += Method2;

See the following .NET interview questions video on Delegate and Events: -


Windows Workflow Foundation(WWF) interview questions: - What is WWF? Explain Workflow? What are different types of Workflow in Windows Workflow Foundation?

Windows Workflow Foundation(WWF) is a programming model for building workflow-enabled applications on windows. System. Workflow namespace has all the necessary modules to develop any type of workflow.

Workflow: -

A Workflow is a set of activities, which is stored as model and they depict a process.  Below figure depicts clearly the difference between Workflow and Activity. Every task is an activity and group of activity depicts a complete workflow. Workflow is run by the Workflow runtime engine.


Workflow model can be written in pure .NET code, pure XAML or Mix of XAML and .NET Code. A workflow model is compiled and can execute under windows, ASP.NET, Web services or windows services application.

Different types of Workflow in Windows Workflow foundation: -

There are two basics type of workflow Sequential Workflow and State machines workflow.

A sequential workflow has clear start and finish boundaries. Workflow controls execution in Sequential workflow. In sequential execution, one task is executed after other. Sequential workflow is more rigid in format and execution path has a determistic nature.

A State machine workflow is more dynamic in nature. Workflow has states and the state waits for events to help it move to next state. In State machine execution path is undetermestic nature.

Below figure shows visual conceptualization of fundamentals. You can see in Sequential workflow the execution path is very determent. Shiv performs the entire task sequentially and these tasks are very determent. Now have a look at the second workflow. Every state goes to other state when it receives some external events. For instance when Shiv is seeing star trek there is an event of flashing news which triggers him to see the flashing new.


See the following video on working of sample of Windows Workflow Foundation(WWF): -


Mar 6

.NET interview questions: - What is Code Access Security (CAS) and how does it work? Is CAS supported in .NET 4.0?

CAS(Code Access Security) is the part of .NET security model which determines whether or not a particular code is allowed to run and what kind of resources can the code access.

CAS working: -

It includes four step process:-

  • First Evidence is gathered about the assembly. In other words from where did this assembly come? , who is the publisher etc.
  • Depending on evidences the assembly is assigned to a code group. In other words what rights does the assembly depending on the evidence gathered.
  • Depending on code group security rights are allocated.
  • Using the security rights the assembly is run with in those rights


                                                                 Figure: - CAS in action

Now let’s find out whether CAS is supported in .NET 4.0 or not

CAS is deprecated in .NET 4.0 and two major changes are brought in:-

  • Permission granting is no more the work of CAS; it’s now the work of the hosting model. In other words CAS is disabled in .NET 4.0 by default. The host will decide what rights to be given to the .NET assembly.
  • A new security model i.e. Security transparent model is introduced. The security transparent model puts code in to separate compartments/ boxes as per the risk associated. If you know a code can do something wrong you can compartmentalize the code as ‘Security transparent’ and if you have a code which you trust you can box them in to ‘Security critical’.

Also see following .NET interview questions video on IL code, CLR, CTS, CAS: -

.NET Design Pattern interview questions: - What is Bridge Pattern?

It is structural Design Pattern which let us separate abstraction from implementation.

What is Abstraction and what is Implementation?

Abstraction means hide all unnecessary things. In object oriented programming we create functions and classes and hide all the complex things from the end developer.
Implementation means actual definition of our abstraction.

Whether it is programming or real life, in general scenario our abstraction is tightly coupled with our implementation. Example – We call function (Abstraction) written inside remote control class which will call function (implementation) written inside TV in turn. In this example we create object of TV class inside RemoteControl class. Bridge pattern is all about decoupling two of them.

How we can decouple them?

There is a very common principle in object oriented design “Program to an interface not to concrete class.”  When we write our program which obeys to this principle our program become loosely coupled.

What does mean by interface here?

It means we should always have a parent of a class (which is going to get used somewhere else. In the Remote Control and TV example TV should have parent like ITV or AbstractTV). That parent is referred as interface in the principle definition.

Why we should decouple them? 

So that both can vary independently. Changing one should not affect other. Example – Just like we take any RemoteControl and attach it to any TV and vice versa.

Step by Step Demo on Bridge Pattern

  1. Create RemoteControl and TV class as follows

  2. Write the code in such a way that “Program to an interface not to concrete class” principle won’t get violated.
  •       Decouple Implementation from the abstraction    



Now client can pass any TV of his choice.

  • Decouple Abstraction code from client code. For that we will do same thing. 



Finally we separated Abstraction from Implementation and now both can vary independently. This is BRIDGE PATTERNS.

Hope you have enjoyed here. If interested to join any technical class including MVC, WCF, Design patterns, WPF, BI, UML, TFS visit or contact

Also see following video on .NET Design Pattern interview questions on Mediator Pattern: -

.NET interview questions: - How can we handle exceptions in .NET?

Following is the .NET interview questions on handing exception.

Exceptions are handled by “System.Exception” base class.  If you want to raise an error from source you need to create the exception object with below code snippet.

    throw new Exception("Customer code cannot be more than 10");

Once the exception is raised if you want to catch the same you need to use the try catch block as shown below.

     // This section will have the code which 
     // which can throw exceptions.    
     catch(Exception e)
     // Handle what you want to
     // do with the exception
label.text = e.Message; }

How can I know from which source the exception occurred?

“System.Exception.StackTrace”allows you to identify series of call which lead to this exception.

What if we do not catch the exception?

If you do not catch the error, .NET framework will handle the same and you will get a message box as shown in the below figure.


Also click and see the following .NET interview questions video on difference between Throw and Throw ex: -: -

.NET interview questions: - What is the difference between .NET 1.X, 2.0, 3.0, 3.5 and 4.0?

One of the basic and most favorite .NET interview questions of the interviewer.

Below is the list of top differences between the framework versions. Please remember the list is much bigger than what I have put down. But for interview perspective I have taken top 5 in each one of them so that we can remember the important ones.

Also click and see the following .NET interview questions with answers video on what is downcasting and upcasting.

.NET interview questions: - Explain Nuget?

One of the frequent .NET interview questions asked during interview is on Nuget.

The amount of frameworks and libraries from both Microsoft (MVC, EF etc) and Non-Microsoft open sources (NUNIT, Log4Net etc) are huge in numbers. These frameworks and libraries keep updating to newer versions and it’s very difficult to keep a track of the same.

As a visual studio developer if you need to reference these frameworks or libraries, you need to do the following:-

  • Search the library URL.
  • Install the library or probably unzip it at some place.
  • Reference the DLL in your visual studio project.
  • If library demands alsomake appropriate changes to the App.config or Web.Config file.


In case you want to revert back you need to follow the above process in a vice-versa fashion.

This is where “Nuget” makes our life easy. “Nuget” is a visual studio extension which helps us to search, locate the library, download them, reference them in our VS project and also make appropriate changes to App and Web config files.


So once you click on “Manage Nuget Package” , you can go and search the framework and click on install. Below is a simple image where I have searched the new version of Entity framework and now we need to just click on the install button to add the same to your visual studio project.


In case you are new to Nuget and do not know how to use it please see this video for basics

Feb 4

ASP.NET interview questions: - Explain Application object and Cache object?

Application object is used when we want data to be shared across users globally in an ASP.NET application.What is the use of cache object?

What is the use of cache object?
It also does the same thing as the application object i.e. sharing and caching global data across ASP.NET pages in a web application.

What is the difference between Cache object and application object?
The main difference between the Cache and Application objects is that the Cache object provides features, such as dependencies and expiration policies.

How can get access to cache object?
The Cache object is defined in the ‘System.Web.Caching’ namespace. You can get a reference to the Cache object by using the Cache property of the HttpContext class in the ‘System.Web’ namespace or by using the Cache property of the Page object.

What are dependencies in cache and types of dependencies?
When you add an item to the cache, you can define dependency relationships that can force that item to be removed from the cache under specific activities of dependencies.Example if the cache object is dependent on file and when the file data changes you want the cache object to be update. Following are the supported dependency:-

  • File dependency: - Allows you to invalidate a specific cache item when a disk based file or files change.
  • Time-based expiration: - Allows you to invalidate a specific cache item depending on predefined time.
  • Key dependency:- Allows you to invalidate a specific cache item depending when another cached item changes.

Also click andsee the following ASP.NET interview questions video onSession vs Viewstate difference.

ASP.NET MVC interview questions: - How to implement AJAX in MVC?

You can implement AJAX in two ways in MVC:-

  • AJAX libraries
  • JQuery

Below is a simple sample of how to implement Ajax by using “Ajax” helper library. In the below code you can see we have a simple form which is created by using “Ajax.BeginForm” syntax. This form calls a controller action called as “getCustomer”. So now the submit action click will be an asynchronous ajax call.

In case you want to make AJAX calls on hyperlink clicks you can use “Ajax.ActionLink” function as shown in the below code.


So if you want to create AJAX asynchronous   hyperlink by name “GetDate” which calls the “GetDate” function on the controller , below is the code for the same.  Once the controller responds this data is displayed in the HTML DIV tag by name “DateDiv”.

Below is the controller code. You can see how “GetDate” function has a pause of 10 seconds.

The second way of making Ajax call in MVC is by using Jquery. In the below code you can see we are making an ajax POST call to a URL “/MyAjax/getCustomer”. This is done by using “$.post”. All this logic is put in to a function called as “GetData” and you can make a call to the “GetData” function on a button or a hyper link click event as you want.

Above is the ASP.NET MVC interview questions & also see the following video on how to build-up single sign-on using ASP.NET forms authentications:  -

ASP.NET interview questions: - What are partial classes in ASP.NET?

A partial class allows a single class to be divided in to two separate physical files. During compile time these files get compiled in to single class. For instance you can see in the below figure we have the customer class divided in to two different files “customer1.cs” and “customer2.cs”.

During compilation these files gets compiled in to single class internally. So when you create an object of the customer class you will be able to see methods lying in both the physical files. For instance you can see “Add” method belongs to “customer1.cs” and “Delete” method belongs to “customer2.cs” , but when the customer object is created we can see both “Add” and “Delete” methods.


                                                      Figure: - Partial classes

Above is the ASP.NET interview questions & also see the following video on Web.config transformation:  -

Jan 2

ASP.NET interview questions: - Show us how will you configure “Web Garden”?

“Web garden” can be configured by using process model settings in “machine.config” or “Web.config” file. The configuration section is named <process Model> and is shown in

See the following example. The process model is enabled by default (enable=”true”). Below is the snippet from config file.

From the above process model section for web garden, we are concerned with only two attributes “web garden” and “cpuMask”.

WebGarden: - Controls CPU affinity. True indicates that processes should be affinities to the corresponding CPU. The default is False.

CpuMask:- Specifies which processors on a multiprocessor server are eligible to run ASP.NET processes. The cpuMask value specifies a bit pattern that indicates the CPUs eligible to run ASP.NET threads. ASP.NET launches one worker process for each eligible CPU. If web Garden is set to false, cpuMask is ignored and only one worker process will run regardless of the number of processors in the machine. If web Garden is set to true, ASP.NET launches one worker process for each CPU that corresponds to a set bit in cpuMask. The default value of cpuMask is 0xffffffff. 

Below are detail steps of how to implement web garden

  • Click Start and then click Run.
  • Type calc.exe and then click OK.
  • Go to View menu, click Scientific.
  • Go to View menu, click Binary.
  • Use zero and one to specify the processors ASP.NET can or cannot use.

Use one for the processor that you want to use for ASP.NET. Use 0 for the processor that you do not want to use for ASP.NET. For example, if you want to use the first two processors for ASP.NET of a four-processor computer, type 1100.

  • On the View menu, click Decimal. Note the decimal number.
  • Open the Web.config or machine.config file in a text editor such as Notepad. The Web.config file is located in the folder where the application is saved.
  • In the Web.config file, add the process Model configuration element under the System. Web element. Before adding <process Model> to Web.config file, the user has to make sure that the allow Definition attribute in the <process Model> section of the Web.config file is set to everywhere.

  • Add and then set the web Garden attribute of the process Model element to True.

  • Add and then set the cpuMask attribute of the process Model element to the result that is determined in your calculation.

Do not preface the number with zerox because the result of the calculation is a decimal number. The following example demonstrates the process Model element that is configured to enable only the first two processors of a four-processor computer.

Save the Web.config file. The ASP.NET application automatically restarts and uses only the specified processors.

See the following ASP.NET interview questions video on ASP.NET Masterpages:  -

.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#:  -