Introduction to
Introduction to
You can use different languages like C#, Cobol, VB, F#, Perl, etc. for writing
.NET framework applications. This Framework supports services, websites,
desktop applications, and many more on Windows. It provides
functionalities such as generic types, automatic memory management,
reflection, concurrency, etc. These functionalities will help to make the
development easier and efficiently build high-quality web as well as client
applications.
This article covers the most frequently asked .NET and .NET Core questions
asked in interviews.
Real-Life Problems
Create My Plan
EXE is an executable file that runs the application for which it is designed.
An EXE is produced when we build an application. Therefore the assemblies
are loaded directly when we run an EXE. However, an EXE cannot be shared
with the other applications.
Dynamic Link Library (DLL) is a library that consists of code that needs
to be hidden. The code is encapsulated inside this library. An application
can consist of many DLLs which can be shared with the other programs and
applications.
4. What is CTS?
CTS stands for Common Type System. It follows a set of structured rules
according to which a data type should be declared and used in the program
code. It is used to describe all the data types that are going to be used in
the application.
We can create our own classes and functions by following the rules in the
CTS. It helps in calling the data type declared in one programming language
by other programming languages.
5. Explain CLS
By
JIT stands for Just In Time. It is a compiler that converts the intermediate
code into the native language during the execution.
Topic Buckets
Mock Assessments
Reading Material
View Tracks
The main differences between value type and reference type are given
below:
A Value Type holds the actual data directly within the memory
location and a reference type contains a pointer which consists of the
address of another memory location that holds the actual data.
Value type stores its contents on the stack memory and reference
type stores its contents on the heap memory.
Assigning a value type variable to another variable will copy the value
directly and assigning a reference variable to another doesn’t copy
the value, instead, it creates a second copy of the reference.
Predefined data types, structures, enums are examples of value
types. Classes, Objects, Arrays, Indexers, Interfaces, etc are examples
of reference types.
Interview Process
Try It Out
Private Assembly:
There are eight events as given below that take place in an order to
successfully render a page:
Page_PreInit
Page_Init
Page_InitComplete
Page_PreLoad
Page_Load
Page_LoadComplete
Page_PreRender
Render
Garbage collector frees the unused code objects in the memory. The
memory heap is partitioned into 3 generations:
Caching means storing the data temporarily in the memory so that the data
can be easily accessed from the memory by an application instead of
searching for it in the original location. It increases the speed and
performance efficiency of an application.
Page caching
Data caching
Fragment caching
Yes. By modifying the following code in the web.config file, we can apply
themes to ASP.NET applications:
<configuration>
<system.web>
<pages theme="windows"/>
</system.web>
</configuration>
Components of MVC
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 back to the database or uses it to
render the same data.
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.
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 and update the database using the Employee Model.
To get the values that are posted on this page to which the page has been
posted, the FindControl method can be used.
When we pass the delegate object in a program, it will call the referenced
method. To create a custom event in a class, we can make use of delegate.
<asp: Login> Provides a login capability that enables the users to enter
their credentials with ID and password fields.
<asp: LoginName> Used to display the user name who has logged-in.
<asp: LoginView> Provides a variety of views depending on the template
that has been selected.
<asp: LoginStatus> Used to check whether the user is authenticated or
not.
<asp: PasswordRecovery> Sends an email to a user while resetting the
password.
Servers insert the MIME header at the beginning of the web transmission to
denote that it is a 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.
CAS gives limited access to code to perform only certain operations instead
of providing all at a given point in time. CAS constructs a part of the
native .NET security architecture.
We can use the appSettings block in the web.config file, if we want to set
the user-defined values for the whole application. Example code given
below will make use of ConnectionString for the database connection
throughout the project:
<em>
<configuration>
<appSettings>
<add key= "ConnectionString" value="server=local; pwd=password;
database=default" />
</appSettings>
</configuration>
</em>
The main difference between an abstract class and an interface are listed
below:
Heap: Heap is a stored reference type that keeps track of the more precise
objects or data. It is used for dynamic memory allocation.
Connect Timeout
Min Pool Size
Max Pool Size
Pooling
Secure: UWP apps will specify which resources of device and data are
accessed by them.
It is possible to use a common API on all devices(that run on Windows
10).
It enables us to use the specific capabilities of the device and adapt
the user interface(UI) to different device screen sizes, DPI(Dots Per
Inches), and resolutions.
It is available on the Microsoft Store on all or specified devices that
run on Windows 10.
We can install and uninstall these apps without any risk to the
machine/incurring “machine rot”.
Engaging: It uses live tiles, user activities, and push notifications, that
interact with the Timeline of Windows as well as with Cortana’s Pick
Up Where I Left Off, for engaging users.
It can be programmable in C++, C#, Javascript, and Visual Basic. For
UI, you can make use of WinUI, HTML, XAML, or DirectX.
3. Open “Solution Explorer” and right-click on the folder “Home” (It is Under
Views), then click on Add New Item. You need to select MVC View Page
Template under ASP.NET Section and rename it as “addition.cshtml” and
then click on the Add button.
@{
ViewBag.Title = "Addition Page";
}
Here, we have created a simple form that is having two text boxes and a
single Add Button. The text boxes are named
as txtFirstNum and txtSecondNum. On the controller page, we can access these
textboxes using:
<form asp-controller="Home" asp-action="add" method="post">
This form will indicate all the submissions will be moved to HomeController
and the method add action will be executed.
5. Open the HomeController.cs and write the following code onto it:
using System;
using Microsoft.AspNetCore.Mvc;
namespace CalculateSum.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
[HttpPost]
public IActionResult add()
{
int number1 =
Convert.ToInt32(HttpContext.Request.Form["txtFirstNum"].ToString());
int number2 =
Convert.ToInt32(HttpContext.Request.Form["txtSecondNum"].ToString());
int res = number1 + number2;
ViewBag.Result = res.ToString();
return View("addition");
}
}
}
In this program, we have added two IAction Methods addition() and add().
Addition() method will return the addition view page and add() method
obtains input from the browser, processes it, and results will be kept in
ViewBag.Result and then returned to the browser.
Now, press Ctrl+F5 for running your program. This will launch
an ASP.NET Core website into the browser. Add /Home/addition at the end of
the link and then hit on enter. The output format is given below:
Conclusion
The .NET is a full-stack software development framework, which is
essentially used to build large enterprise-scale and scalable software
applications. The .NET framework has wide scope in the market. It is a
flexible and user-friendly framework, that goes well along with other
technologies.
The .NET Core was developed in response to the surge in Java popularity.
The .NET Core is normally used in low-risk projects. Some of the .NET
components can be used in .NET core applications (but not the other way
around). This article mainly concentrates on the framework concepts of .Net
and .NET Core. We are sure that it would give you sufficient information and
a fair knowledge of the common questions that will be asked during an
interview.
Useful Resources:
C# Interview
7. What is MEF?
.NET Standard library will be used in case you need to increase the count
of applications that are compatible with your library and reduce surface
area(a piece of code that a user can interact with) of the .NET API which
your library can access if you are okay with it.
9. What is CoreRT?
.NET Core SDK is a set of tools and libraries that allows the developer to
create a .NET application and library for .NET 5 (also .NET Core) and later
versions. It includes the .NET CLI for building applications, .NET libraries and
runtime for the purpose of building and running apps, and the
dotnet.exe(dotnet executable) that runs CLI commands and runs an
application. Here's the link to download.
.NET Core is a runtime and is used for the execution of an application that is
built for it. Whereas ASP.NET Core is a collection of libraries that will form a
framework for developing web applications. ASP.NET Core libraries can be
used on .NET Core as well as on the “Full .NET Framework”.
MSBuild is the free and open-source development platform for Visual Studio
and Microsoft. It is a build tool that is helpful in automating the software
product creation process, along with source code compilation, packaging,
testing, deployment, and documentation creation. Using MSBuild, we can
build Visual Studio projects and solutions without the need of installing the
Visual Studio IDE.
In the Universal Windows Platform(UWP) app, if you open the folder named
project, you will get to see both files namely project.json and *.csproj. But if
you open our previous Console application in .NET Core, you will get to
see project.json and *.xproj files.
No. The Trace class is used for debugging as well as for certain build
releases. It gives execution plan and process timing details. While debug is
used mainly for debugging. Debug means going through the program code
flow during execution time.
Debug and trace allow for monitoring of the application for errors and
exceptions without VS.NET IDE.
Common Type System(CTS) standardizes all the datatypes that can be used
by different programming languages under the .NET framework.
It’s useful to generate a SQL script, whenever you are trying to debug or
deploy your migrations to a production database. The SQL script can be
used in the future for reviewing the accuracy of data and tuned to fit the
production database requirement.
CoreFX is the set of class library implementations for .NET Core. It includes
collection types, console, file systems, XML, JSON, async, etc. It is platform-
neutral code, which means it can be shared across all platforms. Platform-
neutral code is implemented in the form of a single portable assembly that
can be used on all platforms.
There are two main uses of Zero Garbage Collectors. They are:
Using this, you can develop your own Garbage Collection mechanism.
It provides the necessary functionalities for properly doing the
runtime work.
It can be used in special use cases like very short living applications
or almost no memory allocation(concepts such as No-alloc or Zero-
alloc programming). In these cases, Garbage Collection overhead is
not required and it is better to get rid of it.
.NET Core can be said as the newer version of the .NET Framework. It is a
cost-free, general-purpose, open-source application development platform
provided by Microsoft. It is a cross-platform framework because it runs on
various operating systems such as Windows, Linux, and macOS. This
Framework can be used to develop applications like mobile, web, IoT,
machine learning, game, cloud, microservices, etc.
.NET MCQ
1.
RMT
CLR
RC
RCT
3.
System.Web
System.IO
System.Object
System.File
4.
Value types
All data types in .net
Reference types
Communication between multiple languages
7.
System.Int32
System.Int8
System.Int16
System.Int64
8.
GC.Run() method
GC.Collection() method
GC.Finalize() method
GC.Collect() method
9.
manifest
.dll
.exe
core
10.
If the exception does not occur, will the final block get executed?
Static
Serial
Local
Private
12.
What is Roslyn?
NuGet package
LINQ
System
Dapper
15.
Garbage Collector
JIT Compiler
Primitive data types
All of the above
16.
Windows only
Cross-platform
Linux only
MacOS only
17.
CLI tools
Roslyn
CoreFX and CoreCLR
All of the above
21.
What is CoreFX?