SlideShare a Scribd company logo
18
Most read
20
Most read
22
Most read
Top 50 .NET Interview Questions and Answers
Basic .NET Interview Questions for Freshers
1. Describe the components of .NET.
Top 50 .NET Interview Questions and Answers: An Overview
.NET is an ever-evolving framework developed by Microsoft. This powerful open-source development platform has
been driving the software industry for years. It supports services, websites, desktop applications, and many more
on Windows. In this .NET tutorial, we have tried our best to provide you with some of the top .NET Interview
Questions
and Answers. We have segregated the questions into .NET interview questions for freshers, intermediate .NET
Interview Questions, and .NET Interview Questions for experienced to make it easy to go through the questions.
Managed Code
It is managed by CLR.
.NET framework is a must for execution.
Memory management is done through garbage
collection.
Unmanaged Code
It is not managed by CLR.
Does not require a .NET framework for the execution.
The runtime environment takes care of memory
management.
.NET consists of the following components:
1. Common Language Runtime(CLR): It is an execution engine that runs the code and provides services that make
the development process easier. The programs written for the .NET Framework are executed by the CLR
regardless of programming language.
2. Framework Class Library(FCL): It has pre-defined methods and properties to implement common and complex
functions. It will also provide types for dates, strings, numbers, etc. This class library includes APIs for database
connection, file reading and writing, drawing, etc.
3. Base Class Library(BCL): (BCL) has a huge collection of libraries features and functions that help implement
various programming languages such as C#, F#, Visual C++, etc., in the .NET Framework.
4. Common Type System(CTS): It specifies a standard that will mention which type of data and value can be defined
and managed in memory during runtime.
5. Common Language Specification (CLS): CLS will support inter-operability or cross-language integration, which
means it provides a common platform for interacting and sharing information.
2. Differentiate managed from unmanaged code
3. How do you apply themes to ASP.NET applications?
Yes. By modifying the following code in the web.config file, we can apply themes to ASP.NET applications:
BCL is a base class library of classes, interfaces, and value types
It is the foundation of .NET framework applications, components, and controls
Encapsulates a huge number of common functions and makes them easily available for the developers
It provides functionality like threading, input/output, security, diagnostics, resources, globalization, etc.
Also serves the purpose of interaction between the user and the runtime
It also provides namespaces that are used very frequently. for eg: system, system.Activities, etc.
4. What is BCL?
5. Explain the concept of Just-In-Time (JIT) compilation in .NET.
<configuration>
<system.web>
<pages theme="windows"/>
</system.web>
</configuration>
An assembly is a file that is automatically generated by the compiler which consists of a collection of types and
resources that are built to work together and form a logical unit of functionality. In other words, assembly is a
compiled code and logical unit of code. Assemblies are implemented in the form of executable (.exe) or dynamic
link library (.dll) files.
The JIT compiler translates the MSIL code of an assembly to native code and uses the CPU architecture of the
target machine to execute a .NET application.
It also stores the resulting native code to be accessible for subsequent calls.
If a code executing on a target machine calls a non-native method, the JIT compiler converts the MSIL of that
method into native code.
The JIT compiler also enforces type safety in the runtime environment of the .NET Framework.
It checks for the values that are passed to the parameters of any method.
1. Model: They hold data and its related logic. It handles the object storage and retrieval from the databases for an
application. For example: A Controller object will retrieve the employee information from the database.
It manipulates employee data and sends it back to the database or uses it to render the same data.
2. View: View handles the UI part of an application. They get the information from the models for their display. For
example, any employee view will include many components like text boxes, dropdowns, etc.
3. Controller: They handle the user interactions, figure out the responses for the user input, and also render the final
output. For instance, the Employee controller will handle all the interactions and inputs from the Employee View
MVC stands for Model View Controller. It is an architecture to build .NET applications. The three main logical
components of MVC are the model, the view, and the controller.
7. Describe MVC.
6. What is an assembly?
1. Pre - JIT
and update the database using the Employee Model.
A delegate in .NET is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate
a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the
referenced method, without having to know at compile time which method will be invoked. In addition, we could use
delegates to create custom events within a class.
MIME stands for Multipurpose Internet Mail Extensions. It is the extension of the e-mail protocol which lets users use
the protocol to exchange files over emails easily.
Servers insert the MIME header at the beginning of the web transmission to denote that it is an MIME transaction.
Then the clients use this header to select an appropriate ‘player’ for the type of data that the header indicates. Some of
these players are built into the web browser.
9. What is MIME in .NET?
8. What is a delegate in .NET?
10. What are the types of JIT?
public delegate void ScholarHatDelegate();
class ScholarHatClass
{
// custom event
public event ScholarHatDelegate ScholarHatEvent;
}
ScholarHatClass ScholarHatObj = new ScholarHatClass()
ScholarHatObj.ScholarHatEvent += new ScholarHatDelegate();
Boxing is the process of converting a value type into a reference type directly. It is implicit.
Unboxing is the process where the reference type is converted back into a value type. It is explicit.
Here, complete source code is converted into native code in a single cycle (i.e. compiles the entire code into
native code in one stretch)
This is done at the time of application deployment.
In .Net it is called "Ngen.exe"
2. Econo - JIT
In Econo-JIT compilation, the compiler compiles only those methods that are called at run time.
After the execution of this method, the compiled methods are removed from memory.
3. Normal - JIT
In Normal-JIT compilation, the compiler compiles only those methods that are called at run time.
After executing this method, compiled methods are stored in a memory cache.
No further calls to compiled methods will execute the methods from the memory cache.
A garbage collector frees the unused code objects in the memory. The memory heap is partitioned into 3 generations:
1. Generation 0: It holds short-lived objects.
2. Generation 1: It stores medium-lived objects.
3. Generation 2: This is for long-lived objects.
Collection of garbage refers to checking for objects in the generations of the managed heap that are no longer being
used by the application. It also performs the necessary operations to reclaim their memory. The garbage collector
must perform a collection to free some memory space.
During the garbage collection process:
The list of live objects is recognized.
References are updated for the compacted objects.
The memory space occupied by dead objects is recollected. The remaining objects are moved to an older
segment.
System.GC.Collect() method is used to perform garbage collection in .NET.
13. What is Caching?
11. What is a garbage collector?
12. What is boxing and unboxing in .NET?
Example
int x = 15;
object o = j;
int y = (int)o;
// a value type
// boxing
// unboxing
Two types of memories are present in .NET. They are:
The following are the three different types of Caching:
1. Page Caching
2. Data Caching
3. Fragment Caching
We can use the appSettings block in the web.config file, if we want to set the user-defined values for the whole
application.
C# is the primary language of .NET C#, as a language, can do a lot more. C# benefits from the rich standard library
provided by the .NET framework, which includes a wide range of built-in classes and APIs for common programming
tasks such as file I/O, networking, data manipulation, cryptography, and XML processing.
Caching means storing data temporarily in the memory so that the application can access the data from the cache
instead of looking for its original location. This increases the performance of the application and its speed.
System.Runtime.Caching namespace is used for Caching information in .Net.
14. Why C# is important in .NET Development?
15. What is the appSettings section in the web.config file?
16. What are the types of memories supported in the .NET framework?
<em>
<configuration>
<appSettings>
<add key= "ConnectionString" value="server=local; pwd=password; database=default" />
</appSettings>
</configuration>
</em>
Response.Output.Write() is used to get the formatted output.
Manifest is used to store assembly metadata. It contains all the metadata which are necessary for the following
things:
Version of assembly
Security identity
Scope of the assembly
To resolve references to resources and classes
The following are the two types of cookies in ASP.NET. They are:
1. Session Cookie: It resides on the client machine for a single session and is valid until the user logs out.
2. Persistent Cookie: It resides on the user's machine for a period specified for its expiry. It may be an hour, a day, a
month, or never.
1. Stack: Stack is a stored-value type that keeps track of each executing thread and its location. It is used for static
memory allocation.
2. Heap: Heap is a stored reference type that keeps track of more precise objects or data. It is used for dynamic
memory allocation.
The Char data type represents a character in .NET. In .NET, the text is stored as a sequential read-only collection of
Char data types. There is no null-terminating character at the end of a C# string; therefore a C# string can contain
any number of embedded null characters ('0').
The System.String data type represents a string in .NET. A string class in C# is an object of type System.String. The
String class in C# represents a string.
17. What is manifest in .NET Framework?
18. Why do we use Response.Output.Write()?
1. State the differences between .NET Core and Mono
19. What is the difference between string and String in .NET?
20. Explain the different types of cookies available in ASP.NET.
Intermediate .NET Interview Questions
.NET Core
.Net Core is the subset of implementation for the .NET
framework by Microsoft itself.
Mono
Mono is the complete implementation of the .Net
Framework for Linux, Android, and iOS by Xamarin.
.NET Core only permits you to build web applications
and console applications.
Mono permits you to build different application types
available in .NET Framework, including mobile
applications, GUI-enabled desktop apps, etc.
Mono has the built-in capability to be compiled into
WebAssembly-compatible packages.
.NET Core does not have the built-in capability to be
compiled into WebAssembly-compatible packages.
.NET Core is never intended for gaming. You can only
develop a text-based adventure or relatively basic
browser-based game using .NET Core.
Mono is intended for the development of Games. Games
can be developed using the Unity gaming engine that
supports Mono.
2. Explain the different parts of an Assembly.
When an ASP.NET page runs, the page goes through a life cycle in which it performs a series of processing steps.
These include initialization, instantiating controls, restoring and maintaining state, running event handler code, and
rendering.
The different parts of an assembly are:
1. Manifest: An assembly manifest consists of complete metadata required to specify version requirements and
security identity of an assembly, and also the metadata required for defining the assembly scope and resolving
references to classes and resources.
The assembly manifest will be stored in either a standalone PE(Portable Executable) file that holds only assembly
manifest information, or in a PE file (a .exe or .dll) with MSIL(Microsoft intermediate language) code.
2. Type Metadata: Metadata will be automatically generated by the Compilers from the source files and the compiler
will embed this metadata within target output files like .exe, .dll, or a .netmodule(in the case of multi-module
assembly).
3. MSIL: Microsoft Intermediate Language(MSIL) is a code that implements the types. It includes instructions to
load, store, initialize, and call the methods on objects. Along with this, it also includes instructions for control flow,
direct memory access, arithmetic and logical operations, exception handling, etc. This is generated by the
compiler using one or more source code files.
4. Resources: Resources can be a list of related files such as .bmp or .jpg files. These resources are static, which
means they do not change during run time. Resources are not executable items.
3. Explain the page life cycle and order of events.
The following are the various stages or events of the ASP.Net page life cycle.
PreInit
Init
InitComplete
OnPreLoad
Load
Control PostBack Event(s)
LoadComplete
OnPreRender
OnSaveStateComplete
Render Method
UnLoad
1. IEnumerable interface has only a single method - GetEnumerator() and it must return an instance of an object of a
class that implements the IEnumerator interface.
2. ICollection inherits IEnumerable apart from it contains some more methods and IsSynchronized and SyncRoot
properties help to make the collection thread-safe. ICollection supports count property too.
5. What are the requirements needed for connection pooling?
4. What is the difference between IEnumerable and ICollection?
There are three main requirements needed for connection pooling:
1. The presence of an identical connection string for both entities
2. The existence of multiple processes with the same connection parameters
3. The presence of similar security protocols and settings
The Startup class is a fundamental component of the .NET Core web application architecture. It is responsible for
configuring the application and its dependencies.
When the application starts, the Startup class is executed, and it performs the following tasks:
Sets up the environment: The Startup class sets up the hosting environment for the application, such as
development, staging, or production. It also loads the configuration settings for the application.
Configures services: The Startup class is responsible for configuring the services that the application needs to
function correctly.
6. What is the role of the Startup class in .NET Core?
7. Write a program to find a number of characters in a string.
using System;
namespace LogicalProgram
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the string : ");
string message = Console.ReadLine();
//Remove the empty spaces from the message
message = message.Replace(" ", string.Empty);
while (message.Length > 0)
{
Console.Write(message[0] + " : ");
int count = 0;
for (int j = 0; j < message.Length; j++)
{
if (message[0] == message[j])
{
count++;
}
}
Console.WriteLine(count);
message = message.Replace(message[0].ToString(), string.Empty);
Output
}
Enter the string : ScholarHat S : 1
c : 1
h : 1
o : 1
l : 1
a : 2 r : 1 H : 1 t : 1
}
Console.ReadKey();
}
}
9. What is CoreCLR?
CoreCLR is the run-time execution engine provided by the .NET Core. It consists of a JIT compiler, garbage collector,
low-level classes, and primitive data types. .NET Core is a modular implementation of .NET, and can be used as the
base stack for large scenario types, ranging from console utilities to web applications in the cloud.
8. What are some of the security controls present in ASP.NET?
There are five security controls present in ASP.NET:
Run Code >>
1. <asp: PasswordRecovery>: Used to send an email to a user upon performing a password reset operation
2. <asp: Login>: Gives the provisions of login controls with ID and password fields for users to login via credentials
3. <asp: LoginName>: Used to display the name of the user who has logged into the system
4. <asp: LoginStatus>: Used to denote the authentication flag of the user who has logged in
5. <asp: LoginView>: Used to provide a variety of views based on themes upon user login
10. Differentiate .NET Core vs .NET framework.
Installation
Application
Models
Features
Compatibility
Support
Micro-Services
for
Performance and
Scalability
.NET Core
It works based on the principle of “build once, run
.NET framework This framework is compatible with the
anywhere”. It is cross-platform, so it is compatibleWindows operating system only. Even
with different operating systems such as Linux,
Windows, and Mac OS.
though, it was developed
for
supporting software and applications
on all operating systems.
Since it is cross-platform, it is packaged and installed
independently of the OS.
It is installed in the form of a single
package for Windows OS.
It is used for developing both desktop
application and it focuses mainly on the Windowsand web applications, along with this it
It does not support developing the desktop
mobile, web, and Windows store. also supports Windows Forms and
WPF applications.
It is less effective compared to .Net
Core in terms of performance as well
as scalability of applications. It does
not support the microservices’
development and implementation, but
It provides high performance and scalability.
It supports developing and implementing the micro-
services and the user is required to create a REST API
CLI Tools
and
Services
Packaging
Shipping
Deployment
Model
Android
Development
and
REST for its implementation. it supports REST API services.
Yes, ASP.NET is different from ASP. The following are the main differences:
ASP.NET is developed by Microsoft to create dynamic web applications while ASP (Active Server Pages) is
Microsoft's server-side technology used to create web pages.
ASP.NET is compiled while ASP is interpreted.
ASP uses the technology named ADO while ASP.NET uses ADO.NET.
ASP.NET is completely object-oriented while ASP is partially object-oriented.
It is shipped as a collection of Nugget packages. All the libraries that belong to the .Net
Framework are packaged and shipped
all at once.
It does not support the development
of
mobile applications.
It is compatible with open-source mobile app
platforms like Xamarin, via .NET Standard Library.
Developers can make use of tools of Xamarin for
configuring the mobile application for particular
mobile devices like Android, iOS, and Windows
phones.
For all supported platforms, it provides lightweight
editors along with command-line tools. .NET is heavy for CLI(Command Line
Interface) and developers usually
prefer to work on the lightweight CLI.
The updated version of the .NET Core gets initiatedWhen the updated version is released,
on one machine at a time, which means it gets
updated in new folders/directories in the existing
application without affecting it. Thus, we can say that
.NET Core has a very good flexible deployment
model.
it is deployed only on the Internet
Information Server at first.
Inversion of Control (IoC) is a design principle that promotes loose coupling and modularity by inverting the
traditional flow of control in software systems. Instead of objects creating and managing their dependencies, IoC
delegates the responsibility of creating and managing objects to a container or framework. In .NET, IoC is commonly
achieved through frameworks like Dependency Injection (DI) containers, where dependencies are injected into
objects by the container, enabling flexible configuration and easier testing.
12. Is ASP.NET different from ASP? If yes, explain how.
13. Write a code to send an email from an ASP.NET application
11. What is an inversion of control (IoC)? How is it achieved in .NET?
mail message = new mail();
message.From = "abc@gmail.com";
2. What is GAC?
GAC stands for Global Assembly Cache. Whenever CLR gets installed on the machine, GAC comes as a part of it. GAC
specifically stores those assemblies which will be shared by many applications. A Developer tool called Gacutil.exe is
used to add any file to GAC.
1. What are EXE and DLL?
EXE and DLL are assembly executable modules.
15. What are tuples in .Net?
A tuple is a fixed-size collection of elements of either the same or different data types. The user must have to specify
the size of a tuple at the time of declaration just like arrays.
3. What is the purpose of Generics in .NET?
14. What are the differences between custom and user control?
Custom Control
Derives from control
Dynamic Layout
Defines a single-control
It has full toolbox support
Loosely coupled control
User Control
Derives from UserControl
Static Layout
Defines a set of con
Cannot be added to the toolbox
Tightly coupled control
1. EXE: It is an executable file that runs the application for which it is designed. When we build an application, an exe
file is generated. Therefore the assemblies are loaded directly when we run an exe. But an exe file cannot be
shared with other applications.
2. DLL: It stands for dynamic link library that consists of code that needs to be hidden. The code is encapsulated in
this library, an application can have many DLLs and can also be shared with other applications.
Advanced .NET Interview Questions for Experienced
message.To = "xyz@gmail.com";
message.Subject = "Hello";
message.Body = "ScholarHat";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(message);
Generics in .NET provide a powerful way to create classes, structures, interfaces, methods, and delegates that work
with any data type. They allow you to define type-safe data structures and algorithms without committing to a
specific data type at compile time. Generics are commonly used to create type-safe collections for both reference
and value types.
The .NET framework provides an extensive set of interfaces and classes in the System.Collections.Generic
namespace for implementing generic collections.
}
}
using System;
// Driver class
class Test {
}
}
set
{
// using properties
public T value
{
// private data members
private T data;
// We use < > to specify Parameter type
public class GFG<T> {
// Main method
static void Main(string[] args)
{
// instance of float type
// using accessors
get
{
return this.data;
this.data = value;
// instance of string type
GFG<string> name = new GFG<string>();
name.value = "GeeksforGeeks";
Output
}
}
ScholarHat
5
using System;
using System.Threading;
// display GeeksforGeeks
Console.WriteLine(name.value);
// display 5
Console.WriteLine(version.value);
GFG<float> version = new GFG<float>();
version.value = 5.0F;
public class Example
{
public static void Main()
{
// Interrupt a sleeping thread.
var sleepingThread = new Thread(Example.SleepIndefinitely);
sleepingThread.Name = "Sleeping";
sleepingThread.Start();
Thread.Sleep(2000);
4. Explain Thread.Sleep in .NET
The Thread.Sleep() method blocks the current thread for the specified number of milliseconds. In other words, we can
say that it suspends the current thread for a specified time.
Run Code >>
One thread cannot call Thread.Sleep on another thread. Thread.Sleep is a static method that always causes the
current thread to sleep.
Calling Thread.Sleep with a value of Timeout.Infinite causes a thread to sleep until it is interrupted by another thread
that calls the Thread.Interrupt method on the sleeping thread, or until it is terminated by a call to its Thread.Abort
method. The following example illustrates both methods of interrupting a sleeping thread.
Output
Thread.Sleep(1000);
sleepingThread.Interrupt();
Thread 'Sleeping' about to sleep indefinitely.
Thread 'Sleeping' awoken.
sleepingThread = new Thread(Example.SleepIndefinitely);
sleepingThread.Name = "Sleeping2";
sleepingThread.Start();
Thread.Sleep(2000);
sleepingThread.Abort();
}
}
private static void SleepIndefinitely()
{
Console.WriteLine("Thread '{0}' about to sleep indefinitely.",
Thread.CurrentThread.Name);
try {
Thread.Sleep(Timeout.Infinite);
}
catch (ThreadInterruptedException) {
Console.WriteLine("Thread '{0}' awoken.",
Thread.CurrentThread.Name);
}
c a t c h ( T h r e a d A b o r t E x c e p t i o n ) {
Console.WriteLine("Thread '{0}' aborted.",
Thread.CurrentThread.Name);
}
finally
{
Console.WriteLine("Thread '{0}' executing finally block.",
Thread.CurrentThread.Name);
}
Console.WriteLine("Thread '{0} finishing normal execution.",
Thread.CurrentThread.Name);
Console.WriteLine();
}
Run Code >>
Thread 'Sleeping' executing finally block.
Thread 'Sleeping finishing normal execution.
Thread 'Sleeping2' about to sleep indefinitely.
Thread 'Sleeping2' aborted.
Thread 'Sleeping2' executing finally block.
7. What is LINQ?
It is an acronym for Language integrated query which was introduced with Visual Studio 2008. LINQ is a set of
features that extend query capabilities to the .NET framework language syntax that allows data manipulation
irrespective of the data source. LINQ bridges the gap between the world of objects and the world of data.
6. What is Blazor?
Blazor is a new .NET web framework for creating client-side applications using C#/Razor and HTML that runs in the
browser with WebAssembly. It can simplify the process of creating a single page application (SPA) and at the same
time enables full-stack web development using .NET.
5. What is the difference between Function and Stored procedure?
Stored Procedure:
A Stored Procedure is always used to perform a specific task.
It can return zero, one or more values.
It can have both input and output parameters.
Exception handling can be done using a try-catch block.
A function can be called from a Procedure.
Functions:
Functions must return a single value.
It can only have the input parameter.
Exception handling cannot be done using a try-catch block.
A Stored procedure cannot be called from a function.
Using .NET for developing Client-side applications has multiple advantages like:
.NET offers a range of API and tools across all platforms that are stable and easy to use.
modern languages such as C# and F# offer a lot of features that make programming easier and interesting for
developers.
The availability of one of the best IDEs in the form of Visual Studio provides a great .NET development experience
across multiple platforms such as Windows, Linux, and macOS.
.NET provides features such as speed, performance, security, scalability, and reliability in web development that
make full-stack development easier.
Read more: What's New in Blazor with .NET 8: A Guide to Blazor 8 New Features
9. What is an HTTP Handler?
Every request into an ASP.NET application is handled by a specialized component called HTTP handler. It is the most
important component for handling ASP.NET application requests.
10. What is cross-page posting?
Whenever we click on a submit button on a webpage, the data is stored on the same page. But if the data is stored on
a different page and linked to the current one, then it is known as a cross-page posting. Cross-page posting is
achieved by the POSTBACKURL property.
8. Differentiate between ExecuteScalar and ExecuteNonQuery
11. What is a reflection in .NET? Give its practical applications.
Reflection in .NET allows for introspection of types, methods, properties, and other members at runtime. It provides
the ability to examine and manipulate metadata, dynamically invoke methods, and create instances of types. This is
done through the System.Reflection namespace.
ExecuteScalar
Returns the output value
Used for fetching a single value
Does not return the number of affected rows
ExecuteNonQuery
Does not return any value
Used to execute insert and update statements
Returns the number of affected rows
To get the values that are posted on the page to which the page has been posted, the FindControl method can be
used.
In the above code, we are using reflection to get information about the string type such as its full name, namespace,
and whether it's public.
It uses different handlers to serve different files. The handler for the web page creates the page and control objects,
runs your code, and then renders the final HTML.
Following are the default HTTP handlers for ASP.NET:
Page Handler(.aspx): Handles web pages
User Control Handler(.ascx): It handles web user control pages
Web Service Handler(.asmx): Handles web service pages
Trace Handler(trace.axd): It handles trace functionality
Type type = typeof(string);
Console.WriteLine("FullName:" + type.FullName);
Console.WriteLine("Namespace:" + type.Namespace);
Console.WriteLine("Is Public:"+ type.IsPublic);
Abstract Class Interface
Used to declare properties, events, methods, and fields as well. Fields cannot be declared using
interfaces.
Used to declare the behavior of an
implementing class.
Only a public access modifier is
supported.
Provides the partial implementation of functionalities that must be
implemented by inheriting classes.
Different kinds of access modifiers like private, public, protected, etc. are
supported.
It can contain static members.
Multiple inheritances cannot be achieved.
It does not contain static members.
Multiple inheritances are achieved.
During the passport authentication, it first checks the passport authentication cookie, if the cookie is not available the
application redirects to the passport sign-on page. The passport service then authenticates the details of the user on
the sign-on page and if they are valid, stores them on the client's machine and then redirects the user to the
requested page.
The status of a DataReader can be checked easily by using a property called ‘IsClosed.’ It will tell you if the DataReader
is closed or opened.
If it is closed, a true value is returned, and if the reader is open, it returns a false value.
Dynamic Loading: Reflection enables you to load assemblies, types, and resources dynamically at runtime.
Object Creation and Invocation: Reflection allows you to create instances of types dynamically and invoke their
methods, properties, and events at runtime. Introspection and Metadata Inspection: Reflection provides APIs to
inspect the metadata of types, such as fields,
properties, methods, attributes, and interfaces. This information can be used for various purposes, including code
generation, documentation generation, serialization, and data binding.
Serialization and Deserialization: Reflection is used extensively in serialization frameworks like JSON.NET and
XML serialization to dynamically inspect and serialize/deserialize object graphs without requiring explicit type
information. Unit Testing and Mocking: Reflection enables frameworks like NUnit and Moq to dynamically
discover and execute unit tests and create mock objects based on test attributes and method signatures at
runtime. Aspect-Oriented Programming (AOP): Reflection is used in AOP frameworks like PostSharp and
Castle Windsor to apply cross-cutting concerns such as logging, caching, and exception handling dynamically to
methods and classes at runtime.
13. Explain passport authentication.
12. How is the status of a DataReader checked in .NET?
15. How does managed code execute in the .NET framework?
14. What is the difference between an abstract class and an interface?
Four main steps are included in the execution of the managed code. They are:
1. Choosing a compiler that can execute the code written by a user
2. Conversion of the code into Intermediate Language (IL) using a compiler
3. IL gets pushed to CLR, which converts it into native code using JIT
4. Native code is now executed using the .NET runtime
We know that .NET is a full-stack software development framework used to build large enterprise-scale and scalable
software applications. It has a wide scope in the market. It is a flexible and user-friendly framework, that goes well
along with other technologies. If you want to crack your interview for a .NET developer, go through these questions
thoroughly. Consider our .NET Developer Training With Certification and Full-Stack .NET Developer
Certification Training Program.
Summary
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF

More Related Content

PDF
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
PPTX
What is dotnet (.NET) ?
PDF
Introduction to ASP.NET Core
PDF
C# Interview Questions PDF By ScholarHat.pdf
PPTX
.Net Core
PPTX
ASP.NET Core MVC + Web API with Overview
PPTX
Asp.Net Core MVC with Entity Framework
PPTX
Microsoft dot net framework
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
What is dotnet (.NET) ?
Introduction to ASP.NET Core
C# Interview Questions PDF By ScholarHat.pdf
.Net Core
ASP.NET Core MVC + Web API with Overview
Asp.Net Core MVC with Entity Framework
Microsoft dot net framework

What's hot (20)

PPTX
Managing (Schema) Migrations in Cassandra
PDF
API for Beginners
PPTX
SOAP--Simple Object Access Protocol
PPTX
API Design- Best Practices
PPTX
Presentation1.pptx
PDF
Django Rest Framework - Building a Web API
PPTX
Tutorial on developing a Solr search component plugin
PDF
Metadata based statistics for DSpace
PPTX
Understanding REST APIs in 5 Simple Steps
PDF
REST API Basics
PDF
Spring Framework - MVC
PPTX
API Docs with OpenAPI 3.0
PDF
Apache Cassandra multi-datacenter essentials
PDF
An Introduction to the WSO2 API Manager
PDF
What's new in NextJS 13_.pdf
PPTX
REST-API introduction for developers
PPTX
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
PDF
Laravel Introduction
PPTX
Laravel introduction
PPTX
SharePoint Design & Development
Managing (Schema) Migrations in Cassandra
API for Beginners
SOAP--Simple Object Access Protocol
API Design- Best Practices
Presentation1.pptx
Django Rest Framework - Building a Web API
Tutorial on developing a Solr search component plugin
Metadata based statistics for DSpace
Understanding REST APIs in 5 Simple Steps
REST API Basics
Spring Framework - MVC
API Docs with OpenAPI 3.0
Apache Cassandra multi-datacenter essentials
An Introduction to the WSO2 API Manager
What's new in NextJS 13_.pdf
REST-API introduction for developers
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Laravel Introduction
Laravel introduction
SharePoint Design & Development
Ad

Similar to Dot NET Interview Questions PDF By ScholarHat (20)

PDF
Dot net-interview-questions-and-answers part i
PPTX
Dot net-interview-questions-and-answers part i
PDF
tybsc it asp.net full unit 1,2,3,4,5,6 notes
PPT
Inside .net framework
PDF
Top 50 .NET Interview Questions and Answers 2019 | Edureka
PDF
Dotnet basics
PPT
PDF
Dotnet interview qa
PDF
Dot net interview_questions
PDF
Dot net interview_questions
PDF
Dot net interview_questions
PPT
Dot Net Framework
PPTX
VB IMPORTANT QUESTION
PPTX
Net Fundamentals
PPS
dot NET Framework
DOCX
Net Interview questions
PPTX
.Net Framework Introduction
PPTX
PPT
Microsoft.Net
Dot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part i
tybsc it asp.net full unit 1,2,3,4,5,6 notes
Inside .net framework
Top 50 .NET Interview Questions and Answers 2019 | Edureka
Dotnet basics
Dotnet interview qa
Dot net interview_questions
Dot net interview_questions
Dot net interview_questions
Dot Net Framework
VB IMPORTANT QUESTION
Net Fundamentals
dot NET Framework
Net Interview questions
.Net Framework Introduction
Microsoft.Net
Ad

More from Scholarhat (20)

PDF
React Redux Interview Questions PDF By ScholarHat
PDF
React Redux Interview Questions PDF By ScholarHat
PDF
React Router Interview Questions PDF By ScholarHat
PDF
JavaScript Array Interview Questions PDF By ScholarHat
PDF
Java Interview Questions PDF By ScholarHat
PDF
Java Interview Questions for 10+ Year Experienced PDF By ScholarHat
PDF
Infosys Angular Interview Questions PDF By ScholarHat
PDF
DBMS Interview Questions PDF By ScholarHat
PDF
API Testing Interview Questions PDF By ScholarHat
PDF
System Design Interview Questions PDF By ScholarHat
PDF
Python Viva Interview Questions PDF By ScholarHat
PDF
Linux Interview Questions PDF By ScholarHat
PDF
Kubernetes Interview Questions PDF By ScholarHat
PDF
Collections in Java Interview Questions PDF By ScholarHat
PDF
CI CD Pipeline Interview Questions PDF By ScholarHat
PDF
Azure DevOps Interview Questions PDF By ScholarHat
PDF
TypeScript Interview Questions PDF By ScholarHat
PDF
UIUX Interview Questions PDF By ScholarHat
PDF
Python Interview Questions PDF By ScholarHat
PDF
OOPS JavaScript Interview Questions PDF By ScholarHat
React Redux Interview Questions PDF By ScholarHat
React Redux Interview Questions PDF By ScholarHat
React Router Interview Questions PDF By ScholarHat
JavaScript Array Interview Questions PDF By ScholarHat
Java Interview Questions PDF By ScholarHat
Java Interview Questions for 10+ Year Experienced PDF By ScholarHat
Infosys Angular Interview Questions PDF By ScholarHat
DBMS Interview Questions PDF By ScholarHat
API Testing Interview Questions PDF By ScholarHat
System Design Interview Questions PDF By ScholarHat
Python Viva Interview Questions PDF By ScholarHat
Linux Interview Questions PDF By ScholarHat
Kubernetes Interview Questions PDF By ScholarHat
Collections in Java Interview Questions PDF By ScholarHat
CI CD Pipeline Interview Questions PDF By ScholarHat
Azure DevOps Interview Questions PDF By ScholarHat
TypeScript Interview Questions PDF By ScholarHat
UIUX Interview Questions PDF By ScholarHat
Python Interview Questions PDF By ScholarHat
OOPS JavaScript Interview Questions PDF By ScholarHat

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Lesson notes of climatology university.
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Complications of Minimal Access Surgery at WLH
PDF
Pre independence Education in Inndia.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
Institutional Correction lecture only . . .
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
O7-L3 Supply Chain Operations - ICLT Program
Lesson notes of climatology university.
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial disease of the cardiovascular and lymphatic systems
VCE English Exam - Section C Student Revision Booklet
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Complications of Minimal Access Surgery at WLH
Pre independence Education in Inndia.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Microbial diseases, their pathogenesis and prophylaxis
Renaissance Architecture: A Journey from Faith to Humanism
Anesthesia in Laparoscopic Surgery in India
2.FourierTransform-ShortQuestionswithAnswers.pdf

Dot NET Interview Questions PDF By ScholarHat

  • 1. Top 50 .NET Interview Questions and Answers Basic .NET Interview Questions for Freshers 1. Describe the components of .NET. Top 50 .NET Interview Questions and Answers: An Overview .NET is an ever-evolving framework developed by Microsoft. This powerful open-source development platform has been driving the software industry for years. It supports services, websites, desktop applications, and many more on Windows. In this .NET tutorial, we have tried our best to provide you with some of the top .NET Interview Questions and Answers. We have segregated the questions into .NET interview questions for freshers, intermediate .NET Interview Questions, and .NET Interview Questions for experienced to make it easy to go through the questions.
  • 2. Managed Code It is managed by CLR. .NET framework is a must for execution. Memory management is done through garbage collection. Unmanaged Code It is not managed by CLR. Does not require a .NET framework for the execution. The runtime environment takes care of memory management. .NET consists of the following components: 1. Common Language Runtime(CLR): It is an execution engine that runs the code and provides services that make the development process easier. The programs written for the .NET Framework are executed by the CLR regardless of programming language. 2. Framework Class Library(FCL): It has pre-defined methods and properties to implement common and complex functions. It will also provide types for dates, strings, numbers, etc. This class library includes APIs for database connection, file reading and writing, drawing, etc. 3. Base Class Library(BCL): (BCL) has a huge collection of libraries features and functions that help implement various programming languages such as C#, F#, Visual C++, etc., in the .NET Framework. 4. Common Type System(CTS): It specifies a standard that will mention which type of data and value can be defined and managed in memory during runtime. 5. Common Language Specification (CLS): CLS will support inter-operability or cross-language integration, which means it provides a common platform for interacting and sharing information. 2. Differentiate managed from unmanaged code 3. How do you apply themes to ASP.NET applications?
  • 3. Yes. By modifying the following code in the web.config file, we can apply themes to ASP.NET applications: BCL is a base class library of classes, interfaces, and value types It is the foundation of .NET framework applications, components, and controls Encapsulates a huge number of common functions and makes them easily available for the developers It provides functionality like threading, input/output, security, diagnostics, resources, globalization, etc. Also serves the purpose of interaction between the user and the runtime It also provides namespaces that are used very frequently. for eg: system, system.Activities, etc. 4. What is BCL? 5. Explain the concept of Just-In-Time (JIT) compilation in .NET. <configuration> <system.web> <pages theme="windows"/> </system.web> </configuration>
  • 4. An assembly is a file that is automatically generated by the compiler which consists of a collection of types and resources that are built to work together and form a logical unit of functionality. In other words, assembly is a compiled code and logical unit of code. Assemblies are implemented in the form of executable (.exe) or dynamic link library (.dll) files. The JIT compiler translates the MSIL code of an assembly to native code and uses the CPU architecture of the target machine to execute a .NET application. It also stores the resulting native code to be accessible for subsequent calls. If a code executing on a target machine calls a non-native method, the JIT compiler converts the MSIL of that method into native code. The JIT compiler also enforces type safety in the runtime environment of the .NET Framework. It checks for the values that are passed to the parameters of any method. 1. Model: They hold data and its related logic. It handles the object storage and retrieval from the databases for an application. For example: A Controller object will retrieve the employee information from the database. It manipulates employee data and sends it back to the database or uses it to render the same data. 2. View: View handles the UI part of an application. They get the information from the models for their display. For example, any employee view will include many components like text boxes, dropdowns, etc. 3. Controller: They handle the user interactions, figure out the responses for the user input, and also render the final output. For instance, the Employee controller will handle all the interactions and inputs from the Employee View MVC stands for Model View Controller. It is an architecture to build .NET applications. The three main logical components of MVC are the model, the view, and the controller. 7. Describe MVC. 6. What is an assembly?
  • 5. 1. Pre - JIT and update the database using the Employee Model. A delegate in .NET is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. In addition, we could use delegates to create custom events within a class. MIME stands for Multipurpose Internet Mail Extensions. It is the extension of the e-mail protocol which lets users use the protocol to exchange files over emails easily. Servers insert the MIME header at the beginning of the web transmission to denote that it is an MIME transaction. Then the clients use this header to select an appropriate ‘player’ for the type of data that the header indicates. Some of these players are built into the web browser. 9. What is MIME in .NET? 8. What is a delegate in .NET? 10. What are the types of JIT? public delegate void ScholarHatDelegate(); class ScholarHatClass { // custom event public event ScholarHatDelegate ScholarHatEvent; } ScholarHatClass ScholarHatObj = new ScholarHatClass() ScholarHatObj.ScholarHatEvent += new ScholarHatDelegate();
  • 6. Boxing is the process of converting a value type into a reference type directly. It is implicit. Unboxing is the process where the reference type is converted back into a value type. It is explicit. Here, complete source code is converted into native code in a single cycle (i.e. compiles the entire code into native code in one stretch) This is done at the time of application deployment. In .Net it is called "Ngen.exe" 2. Econo - JIT In Econo-JIT compilation, the compiler compiles only those methods that are called at run time. After the execution of this method, the compiled methods are removed from memory. 3. Normal - JIT In Normal-JIT compilation, the compiler compiles only those methods that are called at run time. After executing this method, compiled methods are stored in a memory cache. No further calls to compiled methods will execute the methods from the memory cache. A garbage collector frees the unused code objects in the memory. The memory heap is partitioned into 3 generations: 1. Generation 0: It holds short-lived objects. 2. Generation 1: It stores medium-lived objects. 3. Generation 2: This is for long-lived objects. Collection of garbage refers to checking for objects in the generations of the managed heap that are no longer being used by the application. It also performs the necessary operations to reclaim their memory. The garbage collector must perform a collection to free some memory space. During the garbage collection process: The list of live objects is recognized. References are updated for the compacted objects. The memory space occupied by dead objects is recollected. The remaining objects are moved to an older segment. System.GC.Collect() method is used to perform garbage collection in .NET. 13. What is Caching? 11. What is a garbage collector? 12. What is boxing and unboxing in .NET? Example int x = 15; object o = j; int y = (int)o; // a value type // boxing // unboxing
  • 7. Two types of memories are present in .NET. They are: The following are the three different types of Caching: 1. Page Caching 2. Data Caching 3. Fragment Caching We can use the appSettings block in the web.config file, if we want to set the user-defined values for the whole application. C# is the primary language of .NET C#, as a language, can do a lot more. C# benefits from the rich standard library provided by the .NET framework, which includes a wide range of built-in classes and APIs for common programming tasks such as file I/O, networking, data manipulation, cryptography, and XML processing. Caching means storing data temporarily in the memory so that the application can access the data from the cache instead of looking for its original location. This increases the performance of the application and its speed. System.Runtime.Caching namespace is used for Caching information in .Net. 14. Why C# is important in .NET Development? 15. What is the appSettings section in the web.config file? 16. What are the types of memories supported in the .NET framework? <em> <configuration> <appSettings> <add key= "ConnectionString" value="server=local; pwd=password; database=default" /> </appSettings> </configuration> </em>
  • 8. Response.Output.Write() is used to get the formatted output. Manifest is used to store assembly metadata. It contains all the metadata which are necessary for the following things: Version of assembly Security identity Scope of the assembly To resolve references to resources and classes The following are the two types of cookies in ASP.NET. They are: 1. Session Cookie: It resides on the client machine for a single session and is valid until the user logs out. 2. Persistent Cookie: It resides on the user's machine for a period specified for its expiry. It may be an hour, a day, a month, or never. 1. Stack: Stack is a stored-value type that keeps track of each executing thread and its location. It is used for static memory allocation. 2. Heap: Heap is a stored reference type that keeps track of more precise objects or data. It is used for dynamic memory allocation. The Char data type represents a character in .NET. In .NET, the text is stored as a sequential read-only collection of Char data types. There is no null-terminating character at the end of a C# string; therefore a C# string can contain any number of embedded null characters ('0'). The System.String data type represents a string in .NET. A string class in C# is an object of type System.String. The String class in C# represents a string. 17. What is manifest in .NET Framework? 18. Why do we use Response.Output.Write()? 1. State the differences between .NET Core and Mono 19. What is the difference between string and String in .NET? 20. Explain the different types of cookies available in ASP.NET. Intermediate .NET Interview Questions
  • 9. .NET Core .Net Core is the subset of implementation for the .NET framework by Microsoft itself. Mono Mono is the complete implementation of the .Net Framework for Linux, Android, and iOS by Xamarin. .NET Core only permits you to build web applications and console applications. Mono permits you to build different application types available in .NET Framework, including mobile applications, GUI-enabled desktop apps, etc. Mono has the built-in capability to be compiled into WebAssembly-compatible packages. .NET Core does not have the built-in capability to be compiled into WebAssembly-compatible packages. .NET Core is never intended for gaming. You can only develop a text-based adventure or relatively basic browser-based game using .NET Core. Mono is intended for the development of Games. Games can be developed using the Unity gaming engine that supports Mono. 2. Explain the different parts of an Assembly.
  • 10. When an ASP.NET page runs, the page goes through a life cycle in which it performs a series of processing steps. These include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering. The different parts of an assembly are: 1. Manifest: An assembly manifest consists of complete metadata required to specify version requirements and security identity of an assembly, and also the metadata required for defining the assembly scope and resolving references to classes and resources. The assembly manifest will be stored in either a standalone PE(Portable Executable) file that holds only assembly manifest information, or in a PE file (a .exe or .dll) with MSIL(Microsoft intermediate language) code. 2. Type Metadata: Metadata will be automatically generated by the Compilers from the source files and the compiler will embed this metadata within target output files like .exe, .dll, or a .netmodule(in the case of multi-module assembly). 3. MSIL: Microsoft Intermediate Language(MSIL) is a code that implements the types. It includes instructions to load, store, initialize, and call the methods on objects. Along with this, it also includes instructions for control flow, direct memory access, arithmetic and logical operations, exception handling, etc. This is generated by the compiler using one or more source code files. 4. Resources: Resources can be a list of related files such as .bmp or .jpg files. These resources are static, which means they do not change during run time. Resources are not executable items. 3. Explain the page life cycle and order of events.
  • 11. The following are the various stages or events of the ASP.Net page life cycle. PreInit Init InitComplete OnPreLoad Load Control PostBack Event(s) LoadComplete OnPreRender OnSaveStateComplete Render Method UnLoad 1. IEnumerable interface has only a single method - GetEnumerator() and it must return an instance of an object of a class that implements the IEnumerator interface. 2. ICollection inherits IEnumerable apart from it contains some more methods and IsSynchronized and SyncRoot properties help to make the collection thread-safe. ICollection supports count property too. 5. What are the requirements needed for connection pooling? 4. What is the difference between IEnumerable and ICollection?
  • 12. There are three main requirements needed for connection pooling: 1. The presence of an identical connection string for both entities 2. The existence of multiple processes with the same connection parameters 3. The presence of similar security protocols and settings The Startup class is a fundamental component of the .NET Core web application architecture. It is responsible for configuring the application and its dependencies. When the application starts, the Startup class is executed, and it performs the following tasks: Sets up the environment: The Startup class sets up the hosting environment for the application, such as development, staging, or production. It also loads the configuration settings for the application. Configures services: The Startup class is responsible for configuring the services that the application needs to function correctly. 6. What is the role of the Startup class in .NET Core? 7. Write a program to find a number of characters in a string. using System; namespace LogicalProgram { class Program { static void Main(string[] args) { Console.Write("Enter the string : "); string message = Console.ReadLine(); //Remove the empty spaces from the message message = message.Replace(" ", string.Empty); while (message.Length > 0) { Console.Write(message[0] + " : "); int count = 0; for (int j = 0; j < message.Length; j++) { if (message[0] == message[j]) { count++; } } Console.WriteLine(count); message = message.Replace(message[0].ToString(), string.Empty);
  • 13. Output } Enter the string : ScholarHat S : 1 c : 1 h : 1 o : 1 l : 1 a : 2 r : 1 H : 1 t : 1 } Console.ReadKey(); } } 9. What is CoreCLR? CoreCLR is the run-time execution engine provided by the .NET Core. It consists of a JIT compiler, garbage collector, low-level classes, and primitive data types. .NET Core is a modular implementation of .NET, and can be used as the base stack for large scenario types, ranging from console utilities to web applications in the cloud. 8. What are some of the security controls present in ASP.NET? There are five security controls present in ASP.NET: Run Code >> 1. <asp: PasswordRecovery>: Used to send an email to a user upon performing a password reset operation 2. <asp: Login>: Gives the provisions of login controls with ID and password fields for users to login via credentials 3. <asp: LoginName>: Used to display the name of the user who has logged into the system 4. <asp: LoginStatus>: Used to denote the authentication flag of the user who has logged in 5. <asp: LoginView>: Used to provide a variety of views based on themes upon user login
  • 14. 10. Differentiate .NET Core vs .NET framework. Installation Application Models Features Compatibility Support Micro-Services for Performance and Scalability .NET Core It works based on the principle of “build once, run .NET framework This framework is compatible with the anywhere”. It is cross-platform, so it is compatibleWindows operating system only. Even with different operating systems such as Linux, Windows, and Mac OS. though, it was developed for supporting software and applications on all operating systems. Since it is cross-platform, it is packaged and installed independently of the OS. It is installed in the form of a single package for Windows OS. It is used for developing both desktop application and it focuses mainly on the Windowsand web applications, along with this it It does not support developing the desktop mobile, web, and Windows store. also supports Windows Forms and WPF applications. It is less effective compared to .Net Core in terms of performance as well as scalability of applications. It does not support the microservices’ development and implementation, but It provides high performance and scalability. It supports developing and implementing the micro- services and the user is required to create a REST API
  • 15. CLI Tools and Services Packaging Shipping Deployment Model Android Development and REST for its implementation. it supports REST API services. Yes, ASP.NET is different from ASP. The following are the main differences: ASP.NET is developed by Microsoft to create dynamic web applications while ASP (Active Server Pages) is Microsoft's server-side technology used to create web pages. ASP.NET is compiled while ASP is interpreted. ASP uses the technology named ADO while ASP.NET uses ADO.NET. ASP.NET is completely object-oriented while ASP is partially object-oriented. It is shipped as a collection of Nugget packages. All the libraries that belong to the .Net Framework are packaged and shipped all at once. It does not support the development of mobile applications. It is compatible with open-source mobile app platforms like Xamarin, via .NET Standard Library. Developers can make use of tools of Xamarin for configuring the mobile application for particular mobile devices like Android, iOS, and Windows phones. For all supported platforms, it provides lightweight editors along with command-line tools. .NET is heavy for CLI(Command Line Interface) and developers usually prefer to work on the lightweight CLI. The updated version of the .NET Core gets initiatedWhen the updated version is released, on one machine at a time, which means it gets updated in new folders/directories in the existing application without affecting it. Thus, we can say that .NET Core has a very good flexible deployment model. it is deployed only on the Internet Information Server at first. Inversion of Control (IoC) is a design principle that promotes loose coupling and modularity by inverting the traditional flow of control in software systems. Instead of objects creating and managing their dependencies, IoC delegates the responsibility of creating and managing objects to a container or framework. In .NET, IoC is commonly achieved through frameworks like Dependency Injection (DI) containers, where dependencies are injected into objects by the container, enabling flexible configuration and easier testing. 12. Is ASP.NET different from ASP? If yes, explain how. 13. Write a code to send an email from an ASP.NET application 11. What is an inversion of control (IoC)? How is it achieved in .NET? mail message = new mail(); message.From = "abc@gmail.com";
  • 16. 2. What is GAC? GAC stands for Global Assembly Cache. Whenever CLR gets installed on the machine, GAC comes as a part of it. GAC specifically stores those assemblies which will be shared by many applications. A Developer tool called Gacutil.exe is used to add any file to GAC. 1. What are EXE and DLL? EXE and DLL are assembly executable modules. 15. What are tuples in .Net? A tuple is a fixed-size collection of elements of either the same or different data types. The user must have to specify the size of a tuple at the time of declaration just like arrays. 3. What is the purpose of Generics in .NET? 14. What are the differences between custom and user control? Custom Control Derives from control Dynamic Layout Defines a single-control It has full toolbox support Loosely coupled control User Control Derives from UserControl Static Layout Defines a set of con Cannot be added to the toolbox Tightly coupled control 1. EXE: It is an executable file that runs the application for which it is designed. When we build an application, an exe file is generated. Therefore the assemblies are loaded directly when we run an exe. But an exe file cannot be shared with other applications. 2. DLL: It stands for dynamic link library that consists of code that needs to be hidden. The code is encapsulated in this library, an application can have many DLLs and can also be shared with other applications. Advanced .NET Interview Questions for Experienced message.To = "xyz@gmail.com"; message.Subject = "Hello"; message.Body = "ScholarHat"; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(message);
  • 17. Generics in .NET provide a powerful way to create classes, structures, interfaces, methods, and delegates that work with any data type. They allow you to define type-safe data structures and algorithms without committing to a specific data type at compile time. Generics are commonly used to create type-safe collections for both reference and value types. The .NET framework provides an extensive set of interfaces and classes in the System.Collections.Generic namespace for implementing generic collections. } } using System; // Driver class class Test { } } set { // using properties public T value { // private data members private T data; // We use < > to specify Parameter type public class GFG<T> { // Main method static void Main(string[] args) { // instance of float type // using accessors get { return this.data; this.data = value; // instance of string type GFG<string> name = new GFG<string>(); name.value = "GeeksforGeeks";
  • 18. Output } } ScholarHat 5 using System; using System.Threading; // display GeeksforGeeks Console.WriteLine(name.value); // display 5 Console.WriteLine(version.value); GFG<float> version = new GFG<float>(); version.value = 5.0F; public class Example { public static void Main() { // Interrupt a sleeping thread. var sleepingThread = new Thread(Example.SleepIndefinitely); sleepingThread.Name = "Sleeping"; sleepingThread.Start(); Thread.Sleep(2000); 4. Explain Thread.Sleep in .NET The Thread.Sleep() method blocks the current thread for the specified number of milliseconds. In other words, we can say that it suspends the current thread for a specified time. Run Code >> One thread cannot call Thread.Sleep on another thread. Thread.Sleep is a static method that always causes the current thread to sleep. Calling Thread.Sleep with a value of Timeout.Infinite causes a thread to sleep until it is interrupted by another thread that calls the Thread.Interrupt method on the sleeping thread, or until it is terminated by a call to its Thread.Abort method. The following example illustrates both methods of interrupting a sleeping thread.
  • 19. Output Thread.Sleep(1000); sleepingThread.Interrupt(); Thread 'Sleeping' about to sleep indefinitely. Thread 'Sleeping' awoken. sleepingThread = new Thread(Example.SleepIndefinitely); sleepingThread.Name = "Sleeping2"; sleepingThread.Start(); Thread.Sleep(2000); sleepingThread.Abort(); } } private static void SleepIndefinitely() { Console.WriteLine("Thread '{0}' about to sleep indefinitely.", Thread.CurrentThread.Name); try { Thread.Sleep(Timeout.Infinite); } catch (ThreadInterruptedException) { Console.WriteLine("Thread '{0}' awoken.", Thread.CurrentThread.Name); } c a t c h ( T h r e a d A b o r t E x c e p t i o n ) { Console.WriteLine("Thread '{0}' aborted.", Thread.CurrentThread.Name); } finally { Console.WriteLine("Thread '{0}' executing finally block.", Thread.CurrentThread.Name); } Console.WriteLine("Thread '{0} finishing normal execution.", Thread.CurrentThread.Name); Console.WriteLine(); } Run Code >>
  • 20. Thread 'Sleeping' executing finally block. Thread 'Sleeping finishing normal execution. Thread 'Sleeping2' about to sleep indefinitely. Thread 'Sleeping2' aborted. Thread 'Sleeping2' executing finally block. 7. What is LINQ? It is an acronym for Language integrated query which was introduced with Visual Studio 2008. LINQ is a set of features that extend query capabilities to the .NET framework language syntax that allows data manipulation irrespective of the data source. LINQ bridges the gap between the world of objects and the world of data. 6. What is Blazor? Blazor is a new .NET web framework for creating client-side applications using C#/Razor and HTML that runs in the browser with WebAssembly. It can simplify the process of creating a single page application (SPA) and at the same time enables full-stack web development using .NET. 5. What is the difference between Function and Stored procedure? Stored Procedure: A Stored Procedure is always used to perform a specific task. It can return zero, one or more values. It can have both input and output parameters. Exception handling can be done using a try-catch block. A function can be called from a Procedure. Functions: Functions must return a single value. It can only have the input parameter. Exception handling cannot be done using a try-catch block. A Stored procedure cannot be called from a function. Using .NET for developing Client-side applications has multiple advantages like: .NET offers a range of API and tools across all platforms that are stable and easy to use. modern languages such as C# and F# offer a lot of features that make programming easier and interesting for developers. The availability of one of the best IDEs in the form of Visual Studio provides a great .NET development experience across multiple platforms such as Windows, Linux, and macOS. .NET provides features such as speed, performance, security, scalability, and reliability in web development that make full-stack development easier. Read more: What's New in Blazor with .NET 8: A Guide to Blazor 8 New Features
  • 21. 9. What is an HTTP Handler? Every request into an ASP.NET application is handled by a specialized component called HTTP handler. It is the most important component for handling ASP.NET application requests. 10. What is cross-page posting? Whenever we click on a submit button on a webpage, the data is stored on the same page. But if the data is stored on a different page and linked to the current one, then it is known as a cross-page posting. Cross-page posting is achieved by the POSTBACKURL property. 8. Differentiate between ExecuteScalar and ExecuteNonQuery 11. What is a reflection in .NET? Give its practical applications. Reflection in .NET allows for introspection of types, methods, properties, and other members at runtime. It provides the ability to examine and manipulate metadata, dynamically invoke methods, and create instances of types. This is done through the System.Reflection namespace. ExecuteScalar Returns the output value Used for fetching a single value Does not return the number of affected rows ExecuteNonQuery Does not return any value Used to execute insert and update statements Returns the number of affected rows To get the values that are posted on the page to which the page has been posted, the FindControl method can be used. In the above code, we are using reflection to get information about the string type such as its full name, namespace, and whether it's public. It uses different handlers to serve different files. The handler for the web page creates the page and control objects, runs your code, and then renders the final HTML. Following are the default HTTP handlers for ASP.NET: Page Handler(.aspx): Handles web pages User Control Handler(.ascx): It handles web user control pages Web Service Handler(.asmx): Handles web service pages Trace Handler(trace.axd): It handles trace functionality Type type = typeof(string); Console.WriteLine("FullName:" + type.FullName); Console.WriteLine("Namespace:" + type.Namespace); Console.WriteLine("Is Public:"+ type.IsPublic);
  • 22. Abstract Class Interface Used to declare properties, events, methods, and fields as well. Fields cannot be declared using interfaces. Used to declare the behavior of an implementing class. Only a public access modifier is supported. Provides the partial implementation of functionalities that must be implemented by inheriting classes. Different kinds of access modifiers like private, public, protected, etc. are supported. It can contain static members. Multiple inheritances cannot be achieved. It does not contain static members. Multiple inheritances are achieved. During the passport authentication, it first checks the passport authentication cookie, if the cookie is not available the application redirects to the passport sign-on page. The passport service then authenticates the details of the user on the sign-on page and if they are valid, stores them on the client's machine and then redirects the user to the requested page. The status of a DataReader can be checked easily by using a property called ‘IsClosed.’ It will tell you if the DataReader is closed or opened. If it is closed, a true value is returned, and if the reader is open, it returns a false value. Dynamic Loading: Reflection enables you to load assemblies, types, and resources dynamically at runtime. Object Creation and Invocation: Reflection allows you to create instances of types dynamically and invoke their methods, properties, and events at runtime. Introspection and Metadata Inspection: Reflection provides APIs to inspect the metadata of types, such as fields, properties, methods, attributes, and interfaces. This information can be used for various purposes, including code generation, documentation generation, serialization, and data binding. Serialization and Deserialization: Reflection is used extensively in serialization frameworks like JSON.NET and XML serialization to dynamically inspect and serialize/deserialize object graphs without requiring explicit type information. Unit Testing and Mocking: Reflection enables frameworks like NUnit and Moq to dynamically discover and execute unit tests and create mock objects based on test attributes and method signatures at runtime. Aspect-Oriented Programming (AOP): Reflection is used in AOP frameworks like PostSharp and Castle Windsor to apply cross-cutting concerns such as logging, caching, and exception handling dynamically to methods and classes at runtime. 13. Explain passport authentication. 12. How is the status of a DataReader checked in .NET? 15. How does managed code execute in the .NET framework? 14. What is the difference between an abstract class and an interface?
  • 23. Four main steps are included in the execution of the managed code. They are: 1. Choosing a compiler that can execute the code written by a user 2. Conversion of the code into Intermediate Language (IL) using a compiler 3. IL gets pushed to CLR, which converts it into native code using JIT 4. Native code is now executed using the .NET runtime We know that .NET is a full-stack software development framework used to build large enterprise-scale and scalable software applications. It has a wide scope in the market. It is a flexible and user-friendly framework, that goes well along with other technologies. If you want to crack your interview for a .NET developer, go through these questions thoroughly. Consider our .NET Developer Training With Certification and Full-Stack .NET Developer Certification Training Program. Summary Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF