.NET Interview Questions – Part 18

1.What is MS-IL (Microsoft Intermediate Language) ?

When a program is complied in .Net , the source code will be converted into an intermediate language called  Microsoft Intermediate Language (MS-IL) . This is done by Just-In time Complier (JIT). .Net framework is built in such a way that , Code is Just-In time complied, that is it get complied when it is called rather compiling entire code at the start up. A portion of the code will get complied only once and it will exists till the application exit. This will have a significant improvement in performance since  entire section of the code wont get executed in most cases.
Dot Net Interview Questions and Answers on CLR, CTS, CLS

2.What is Common Language Runtime (CLR) ?

Common Language Runtime or CLR is the run-time execution environment of .Net Framework. Converting MS-IL into platform or OS specific code is done by CLR. Currently .Net programs will run only in windows.

3.What is Common Type System (CTS)?

.Net uses Common Type System (CTS)  for Language Interoperability. CTS defines the predefined data types that are available in IL, so that all languages that target the .NET framework will produce compiled code that is ultimately based on these types. So that a data type defined in a VB.net will be understood by C#. For example, VB.Net uses  “Integer” to define data type Integer. C# uses  “int” to define data type Integer. When VB.Net code is complied , it will convert Integer to Int32 and since C# refers Int to Int32 VB.Net code will be understood by C#.

4.What is Common Language Specification (CLS)?

Common Language Specification (CLS) is also used for Language Interoperability in tandem with CTS to ensure Language Interoperability. CLS defines a set of minimum standards that all compilers targeting .NET must support. For example VB.Net is not case sensitive. So attribute “EmployeeName” and “employeename” is considered same. But C# is case sensitive. So for language interoperability , C# doesn’t allow two variable which differs only in Case.
Dot Net Interview Questions and Answers on Garbage Collector

5.What is Garbage Collector ?

Garbage Collector is used in .Net Framework for memory management. While running an application, application request for memory for its internal use. Framework allocates memory from the heap. Once the process is completed , allocated need to be reclaimed for future use. The process of reclaiming unused memory is taken care by Garbage Collector.

6.How to invoke garbage collector programmatically?

To call  garbage collector programmatically, use code “ GC.Collect(); “

7.What is a Managed Code?

Managed code is code that cane be executed and managed by .NET Framework Common Language Runtime. All code based on Intermediate language executes as managed code.
Dot Net Interview Questions and Answers on Assembly

8.What are the new features in .Net Framework 4.0 & 4.5 ?

.NET for Windows Store Apps
Portable Class Libraries for Cross-Platform Development with the .NET Framework.
Core New Features and Improvements (Reduce system restarts, Support for large arrays whose sizeis greater than 2 GB, Optional JIT compilation for multicore processors etc)
Tools (Resource File Generator for Windows Store Apps)
Parallel Computing
Web (Supports HTML5, Web Sockets protocol etc)
Windows Presentation Foundation (WPF)
Windows Communication Foundation (WCF)
Windows Workflow Foundation (WF)

9.What is an Assembly ?

Assemblies are self-describing logical unit, consisting of one or more files targeted at .Net. An assembly can be stored across single file such as a single DLL or EXE that includes meta data, or it can be stored in multiple files, for example, resource files, meta data, DLL’s, and an EXE. Assemblies support versioning.

10.What is Assembly Manifest?

Part of assembly which contains assembly meta data that describes the assembly itself is known as  manifest.  Assembly manifest contain Assembly Name ,Version Number,Culture, Strong name, List of files inside the assembly and Reference information

11.What are different types of Assembly?

The two types of Assemblies are Shared and Private.

12.What is Private Assembly ?

Private Assemblies are intended to be used by the program for which its made for. This is because application will only load private assemblies that are located in the same folder or in a sub folder that the main executable is loaded.

13.What is Shared Assembly ?

Shared Assemblies contain Common Libraries which are intended to be used by multiple applications. While making shared assemblies, Name Collisions and Overwriting existing Assemblies need to be taken care. Name Collisions can be taken care by strong name. And global assembly cache can be used to avoid assembly overwriting.

14.How  to view a Assembly information ?

By using  Ildasm.exe  which is an MSIL Disassembler one can view attributes,  references to other modules and assemblies

15.Where is the assembly version information stored ?

In the Manifest.

16.What is NameSpace?

Namespace is a logical grouping of related classes and types. Every class should have a NameSpace.

17.What is the Difference between NameSpace and Assembly?

1) Form the logical boundary for a Group of classes.
2) It is a Collection of names wherein each name is Unique.
3) Namespace must be specified in Project-Properties.

1)  Assemblies are Self-Describing
2)  It is an Output Unit. It is a unit of Deployment & a unit of versioning. Assemblies contain MSIL code.

18.What is Global Assembly Cache (GAC) ?

While using shared assemblies, to avoid Assembly being overwritten by a different version of the same assembly , shared assemblies are placed in a special directory subtree in the file system, known as the global assembly cache (GAC). Placing shared assemblies can be done by special .Net Utilities Only.

19.What is concept of strong names ?

While using shared assemblies, in order to avoid name collisions strong names are used. Strong Names are based on private key cryptography , ie private assemblies are simply given the same name as their main file name.

20.How to add and remove a assembly from GAC?

To install assembly in Cache use  Gacutil. Goto “Visual Studio Command Prompt” and type “gacutil -i
<assembly_name>”, where (assembly_name) is the DLL name of the project.  To uninstall assembly, type gacutil –u <assembly name> in  Visual Studio Command Prompt.
Dot Net Interview Questions and Answers on reflection and JIT

21.What is Reflection?

Reflection is used to dynamically load a class , create object and invoke methods at runtime. It can also be used read its own meta data to find assemblies, modules and type information at runtime.

22.What is Delay signing ?

To create a strong named assembly and want this assembly to be used by someone else, we partially build this assembly by provide a Public Key. We write this Public Key in the AssemblyInfo.vb OR .cs file. We also add an attribute by the named <Assembly:AssemblyDelaySignAttribute(true)> to the assembly info file. This makes it sure that when we build the assembly, It would be containing the information only about the public key before we deliver it to our client. This is a partial strong named assembly that we have created, and hence it is called Delayed Assembly.

23.What are different type of JIT ?

Different Types of JIT are
1) Pre-JIT –  Complies complete source code into native code at the time of deployment
2) Econo-JIT  – Complies methods that are called at runtime.
3) Normal-JIT – Complies methods that are called at runtime and get stored in cache. Next time when the same method is called, it will be taken from cache.

24.What are Value types and Reference types ?

There are two types of data types in .Net,  Value types and Reference types.Value types are stored in stack part of the memory. Reference type are stored in managed heap. Let have a look at the example for better understanding.
Int iCount = 0; \ Value Type
int NewiCount =  iCount; \  Reference Type

24.What is concept of Boxing and Unboxing ?

Converting a value type to reference type is called Boxing. Converting a reference type to value type is called Unboxing.

25.What’s difference between System exceptions and Application exceptions?

System exceptions are common exceptions thrown by the CLR of .Net Framework. Application exceptions can be user defined exceptions thrown by the application.

26.What is CODE Access security?

CODE Access security is a security model that lets us grant or deny execution permissions to an assembly according to its “properties,” called evidence, such as its strong name or publisher

27.What is a satellite assembly?

A satellite assembly are used when multilingual (UI) application are created. Satellite assembly is a compiled library that contains localize resources  which provides us with the capability of designing and deploying solutions to multiple cultures, rather than hard coding texts, bitmaps etc
Dot Net Interview Questions and Answers on Framework Tools

28.How to prevent my .NET DLL to be decompiled ?

We can prevent .NET DLL to be decompiled up to an extent by Obfuscate Source code, asymmetric encryption and encrypted w32 wrapper application.

29.What is Native Image Generator (Ngen.exe) ?

Ngen.exe creates compiled processor-specific machine code called native images, which are files  and installs them into the native image cache on the local computer. The run-time will use native images from the cache rather than using the JIT compiler to compile the original assembly.

30.What is Code Document Object Model (CodeDom) ?

Code Document Object Model are code generators which are used  to minimize repetitive coding tasks, and to minimize the number of human-generated source code lines.

31.What’s the difference between Response.Write() andResponse.Output.Write()?

Response.Output.Write() allows you to write formatted output.

32.What methods are fired during the page load?

Init() – when the page is instantiated
Load() – when the page is loaded into server memory
PreRender() – the brief moment before the page is displayed to the user as HTML
Unload() – when page finishes loading.

33.When during the page processing cycle is ViewState available?

After the Init() and before the Page_Load(), or OnLoad() for a control.

34.What namespace does the Web page belong in the .NET Framework class hierarchy?


35.Where do you store the information about the user’s locale?


36.What’s the difference between Codebehind=”MyCode.aspx.cs” andSrc=”MyCode.aspx.cs”?

CodeBehind is relevant to Visual Studio.NET only.

37.What’s a bubbled event?

When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

38.Suppose you want a certain ASP.NET function executed on MouseOver for a certain button.  Where do you add an event handler?

Add an OnMouseOver attribute to the button.  Example: btnSubmit.Attributes.Add(“onmouseover”,”someClientCodeHere();”);

39.What data types do the RangeValidator control support?

Integer, String, and Date.

40.Explain the differences between Server-side and Client-side code?

Server-side code executes on the server.  Client-side code executes in the client’s browser.

41.What type of code (server or client) is found in a Code-Behind class?

The answer is server-side code since code-behind is executed on the server.  However, during the code-behind’s execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser.  But just to be clear, code-behind executes on the server, thus making it server-side code.

42.Should user input data validation occur server-side or client-side?  Why?

All user input data validation should occur on the server at a minimum.  Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user.

43.What is the difference between Server.Transfer and Response.Redirect?  Why would I choose one over the other?

Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client’s browser.  This provides a faster response with a little less overhead on the server.  Server.Transfer does not update the clients url history list or current url.  Response.Redirect is used to redirect the user’s browser to another page or site.  This performas a trip back to the client where the client’s browser is redirected to the new page.  The user’s browser history list is updated to reflect the new address.

44.Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

Valid answers are:
· A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
· A DataSet is designed to work without any continuing connection to the original data source.
· Data in a DataSet is bulk-loaded, rather than being loaded on demand.
· There’s no concept of cursor types in a DataSet.
· DataSets have no current record pointer You can use For Each loops to move through the data.
· You can store many edits in a DataSet, and write them to the original data source in a single operation.
· Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.

45.What is the Global.asax used for?

The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

46.What are the Application_Start and Session_Start subroutines used for?

This is where you can set the specific variables for the Application and Session objects.

47.Can you explain what inheritance is and an example of when you might use it?

When you want to inherit (use the functionality of) another class.  Example: With a base class named Employee, a Manager class could be derived from the Employee base class.

48.Describe the difference between inline and code behind.

Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

49.Explain what a diffgram is, and a good use for one?

The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML.  A good use is reading database data to an XML file to be sent to a Web Service.

50.Whats MSIL, and why should my developers need an appreciation of it if at all?

MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.  MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer.

51.Which method do you invoke on the DataAdapter control to load your generated dataset with data?

The Fill() method.

52.Can you edit data in the Repeater control?

No, it just reads the information from its data source.

53.Which template must you provide, in order to display data in a Repeater control?


54.How can you provide an alternating color scheme in a Repeater control?

Use the AlternatingItemTemplate.

55.What property must you set, and what method must you call in your code, in order to bind the data from a data source to the Repeater control?

You must set the DataSource property and call the DataBind method.

56.What base class do all Web Forms inherit from?

The Page class.

57.Name two properties common in every validation control?

ControlToValidate property and Text property.

58.Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?

DataTextField property.

59.Which control would you use if you needed to make sure the values in two different controls matched?

CompareValidator control.

60.How many classes can a single .NET DLL contain?

It can contain many classes.

61.Whats an assembly?

Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.
Describe the difference between inline and code behind – which is best in a loosely coupled solution? ASP.NET supports two modes of page development: Page logic code that is written inside <script runat=server> blocks within an .aspx file and dynamically compiled the first time the page is requested on the server. Page logic code that is written within an external class that is compiled prior to deployment on a server and linked “behind” the .aspx file at run time.

62.Explain what a diffgram is, and a good use for one?

A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order.

63.Where would you use an iHTTPModule, and what are the limitations of anyapproach you might take in implementing one?

One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module.

64.In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events?

Every Page object (which your .aspx page is) has nine events, most of which you will not have to worry about in your day to day dealings with ASP.NET. The three that you will deal with the most are: Page_Init, Page_Load, Page_PreRender.

65.Which method do you invoke on the DataAdapter control to load your generated dataset with data?

If my DataAdapter is sqlDataAdapter and my DataSet is dsUsers then it is called this way:

66.Which template must you provide, in order to display data in a Repeater control?


67.What is .Net Framework ?

The .NET framework is a programming framework from Microsoft. Developers can use .Net Framework to develop applications, install and run the application on Windows operating systems. Applications that can run on .Net Framework are

Console applications
Windows Forms applications
ASP.NET applications for web based applications
Windows services
Web services (XML, SOAP and WSDL)
Windows Presentation Foundation (WPF) applications
Windows Communication Foundation (WCF) applications
Windows Workflow Foundation (WF) for Workflow-enabled applications

68.What are the advantages of Dot Net?

Good Design
Object-Oriented Programming –  Using C# and .NET  which are based on object-oriented Concepts.
Language Independence –  All the languages which are supported by .Net ( VB.NET, C#, J#, and managed C++ ) are compiled in to common Intermediate Language (IL) . So IL make sure that languages are interoperable.
Efficient Data Access – ADO.NET  provide fast and efficient way to access RDBMS, file system etc
Code Sharing – .To share code between applications, a new concept called assembly is introduced. Assemblies supports  versioning.
Improved Security
Support Dynamic Web Pages –  Using ASP.NET.
Support for Web Services

69.How can you provide an alternating color scheme in a Repeater control?

AlternatingItemTemplate Like the ItemTemplate element, but rendered for every other
row (alternating items) in the Repeater control. You can specify a different appearance
for the AlternatingItemTemplate element by setting its style properties.

70.What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?

You must set the DataMember property which Gets or sets the specific table in the DataSource to bind to the control and the DataBind method to bind data from a source to a server control. This method is commonly used after retrieving a data set through a database query.

71.What base class do all Web Forms inherit from?


72. What method do you use to explicitly kill a user’s session?

The Abandon method destroys all the objects stored in a Session object and releases their resources.
If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.
Syntax: Session.Abandon

73. How do you turn off cookies for one page in your site?

Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, this
property instructs the client application not to save the Cookie on the user’s hard disk when a session ends.

74. Which two properties are on every validation control?

ControlToValidate & ErrorMessage properties

75. How do you create a permanent cookie?

Setting the Expires property to MinValue means that the Cookie never expires.

76. Which method do you use to redirect the user to another page without performing a round trip to the client?


77. What is the transport protocol you use to call a Web service?

SOAP. Transport Protocols: It is essential for the acceptance of Web Services that they are based on established Internet infrastructure. This in fact imposes the usage of of the HTTP, SMTP and FTP protocols based on the TCP/IP family of transports. Messaging Protocol: The format of messages exchanged between Web Services clients and Web Services should be vendor neutral and should not carry details about the technology used to implement the service. Also, the message format should allow for extensions and different bindings to specific transport protocols. SOAP and ebXML Transport are specifications which fulfill these requirements. We expect that the W3C XML Protocol Working Group defines a successor standard.

78. Define namespace?

The namespace are known as containers which will be used to organize the hierarchical set of .Net classes.

79. What is a code group?

A code group is a set of assemblies that share a security context.

80. What are sealed classes in C#?

The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class.

81. What is the difference between static and instance methods?

A method declared with a static modifier is a static method. A static method does not operate on a specific instance and can only access static members.A method declared without a static modifier is an instance method. An instance method operates on a specific instance and can access both static and instance members. The instance on which an instance method was invoked can be explicitly accessed as this. It is an error to refer to this in a static method.

82. How many languages .NET is supporting now?

When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. 44 languages are supported.

83. How many .NET languages can a single .NET DLL contain?


84. What is metadata?

Metadata means data about the data i.e., machine-readable information about a resource, . Such information might include details on content, format, size, or other characteristics of a data source. In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information.

85. What is the difference between Custom Control and User Control?

Custom Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time.
AUser Control is shared among the single application files.

86. What keyword is used to accept a variable number of parameter in a method?

“params” keyword is used as to accept variable number of parameters.

87. What is boxing and unboxing?

Implicit conversion of value type to reference type of a variable is known as BOXING, for example integer to object type conversion.
Conversion of reference type variable back to value type is called as UnBoxing.

88. What is object?

An object is an instance of a class. An object is created by using operator new. A class that creates an object in memory will contain the information about the values and behaviours (or methods) of that specific object.

89. What is the difference between the Response.Write() and Response.Output.Write() methods?

The Response.Write() method allows you to write the normal output; whereas, theResponse.Output.Write() method allows you to write the formatted output.

90. What does the Orientation property do in a Menu control?

Orientation property of the Menu control sets the horizontal or vertical display of a menu on a Web page. By default, the orientation is vertical.

91. Which method is used to force all the validation controls to run?

The Page.Validate() method is used to force all the validation controls to run and to perform validation.

92. Which method has been introduced in ASP.NET 4.0 to redirect a page permanently?

The RedirectPermanent() method added in ASP.NET 4.0 to redirect a page permanently. The following code snippet is an example of the RedirectPermanent() method:


93. Differentiate between client-side and server-side validations in Web pages.

Client-side validations take place at the client end with the help of JavaScript and VBScript before the Web page is sent to the server. On the other hand, server-side validations take place at the server end.

94. What is the default timeout for a Cookie?

The default time duration for a Cookie is 30 minutes.

95. How can you register a custom server control to a Web page?

You can register a custom server control to a Web page using the @Register directive.

96. Which ASP.NET objects encapsulate the state of the client and the browser?

The Session object encapsulates the state of the client and browser.

97.How can I see what assemblies are installed in the global assembly cache?

The .NET Framework ships with a Windows shell extension for viewing the assembly cache. Navigating to % windir%assembly with the Windows Explorer activates the viewer.

98.What is garbage collection?

Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a “finalizer,” which is written by the user). Some garbage collectors, like the one used by .NET, compact memory and therefore decrease your program’s working set.

99.How does non-deterministic garbage collection affect my code?

For most programmers, having a garbage collector (and using garbage collected objects) means that you never have to worry about deallocating memory, or reference counting objects, even if you use sophisticated data structures. It does require some changes in coding style, however, if you typically deallocate system resources (file handles, locks, and so forth) in the same block of code that releases the memory for an object. With a garbage collected object you should provide a method that releases the system resources deterministically (that is, under your program control) and let the garbage collector release the memory when it compacts the working set.

100.What is the Common Language Specification (CLS)?

The Common Language Specification is a set of constructs and constraints that serves as a guide for library writers and compiler writers. It allows libraries to be fully usable from any language supporting the CLS, and for those languages to integrate with each other. The Common Language Specification is a subset of the common type system. The Common Language Specification is also important to application developers who are writing code that will be used by other developers. When developers design publicly accessible APIs following the rules of the CLS, those APIs are easily used from all other programming languages that target the common language runtime.

101.What is the Microsoft Intermediate Language (MSIL)?

MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.
Combined with metadata and the common type system, MSIL allows for true cross-language integration.
Prior to execution, MSIL is converted to machine code. It is not interpreted.

102.What is the use of “GLOBAL.ASAX” file?

It allows to execute ASP.NET application level events and setting application-level variables.

103.Which class does the remote object has to inherit?

All remote objects should inherit from System.MarshalbyRefObject.

104.What is compile time and runtime polymorphism?

Method overloading is the example for compile time and method overriding is the example for runtime polymorphism.

105.What is the default access modifier of a class and its members?

Default Access modifier of a class is internal and default access modifier of the class members is private.




This site uses Akismet to reduce spam. Learn how your comment data is processed.