Easy way to IT Job

Dot Net Interview Questions and Answers
Share on your Social Media

Dot Net Interview Questions and Answers

Published On: April 1, 2022

Dot Net Interview Questions and Answers

Dot Net is a popular framework used to develop web services and web applications. It provides a comprehensive environment to run, debug, and deploy code for developing applications with the use of functionalities like libraries, APIs, and classes. Dot Net is based on Object-Oriented Programming and it was developed by Microsoft. Dot Net is widely used by global web application developers as it has specialized characteristics like free and open-source, cross-platform, sharable, friendly, and fast. We have shared here some of the frequently asked interview questions and answers to help you perform well in the technical rounds of top companies.

Dot Net Interview Questions and Answers for Freshers

1. What are languages can be used in the .Net framework?

In .Net Framework, we can use various programming languages like C#, Cobol, VB, Perl, and so on for developing web applications and web services. We can develop desktop applications, websites, and support services in the .Net framework as it provides features such as generic types, reflection, automatic memory management, concurrency, etc.

2. Define Dot Net Core

  • Dot Net Core is the latest version of the .Net framework and it is a cost-free, general-purpose, and open-source platform developed by Microsoft.
  • Dot Net is a cross-platform framework and we can develop and run applications in various operating systems like Windows, Linux, and macOS. It can be used to develop different kinds of applications like mobile, IoT, web, machine learning, game, and microservices.

3. What is the Dot Net architecture and how does it work?

  • The fundamental blocks of the .Net framework are Source code, native compiler, Common Intermediate Language (CIL), Common Language Runtime (CLR), and Executable code.
  • The .Net applications will be written in supportive languages like F#, VB, or C# and then they will be compiled to CIL (Common Intermediate Language).
  • Then the compiled code will be stored as an assembly file with a .dll or .exe file extension. Then the CLR (Common Language Runtime) takes the assembly file to convert them into machine code with the help of the JIT (Just-In_Time) compiler.
  • Finally, the machine code can execute the specific application in the computer.

4. What are the major components of the .Net framework?

The major components of the .Net framework are CLR (Common Language Runtime) as an executive engine, FCL (Framework Class Library) that has pre-defined methods, BCL (Base Class Library) that has a huge collection of libraries and functions, CTS (Common Type System) that specifies a standard, and CLS (Common Language Specification) that defines rules and regulations.

5. Define CLR

  • CLR is Common Language Runtime that serves as an executive engine in the .Net framework and it runs the code with services that make the development process easier and faster.
  • It provides various services such as garbage collection, memory management, exception handling, type safety, thread management, and security.
  • CLR makes the designing of the applications and components easier. Every .Net framework will have CLR as default and the applications and programs written in the .Net framework are executed by the CLR irrespective of the programming language.

6. Define FCL

  • FCL stands for Framework Class Library which has predefined methods and properties to implement complicated and common functions used by .Net applications.
  • It provides types for dates, strings, numbers, etc. The class library includes APIs for file reading and writing, database connection, drawing, and so on.

7. What is BCL and how is it classified in the .Net framework?

  • BCL stands for Base Class Library which has a wide range of libraries and functions for implementing various programming languages like C#, F#, Visual Basic, Visual C++, etc in the .Net Framework.
  • BCL is classified into two parts such as User-Defined Library and Predefined Class Library.
  • User-Defined Class Library includes assemblies. Assembly is considered the main building block of the .Net Framework. An assembly in the CLI (Common Language Infrastructure) is a logical unit of code used for security, versioning, and deployment.
  • It can be defined in two forms Dynamic Link Library (.dll), and Executable (.exe) files. During the compilation process, metadata with MSIL (Microsoft Intermediate Language) will be generated and stored in a file called Assembly.
  • Predefined Class Library contains namespace. A namespace is the collection of in-built methods and classes of the .Net framework.
  • The namespace will be added to any .Net program with the method of “using the system”. In this, ‘using’ represents a keyword and ‘system’ represents a namespace.

8. Explain about CTS

  • CTS stands for Common Type System and it specifies a standard for the type of data and value that can be defined and managed in memory during runtime.
  • It ensures that the programming data is defined in various languages for interacting with each other to share the information.
  • For instance, in VB.Net we define datatype as integer whereas in C# we define int as a datatype. It is used to prevent or avoid data loss during the data transfer from a type in one language to its equivalent type in another.

9. Define CLS

  • CLS is the abbreviation for Common Language Specification which is the subset of CTS to define a set of rules and regulations to be followed by .Net Framework Language.
  • It supports interoperability or cross-language integration by providing a common platform for interaction and sharing information.
  • For instance, every programming language such as C#, F#, VB.Net under the .net framework will have its own syntax and the statements belonging to that language should get executed in a common platform and it is the CLS that provides interaction and information sharing.

10. Define JIT

JIT is the Just-In-Time compiler that converts the intermediate code into native language code during the execution of .Net programs.

11. Differentiate int and int32

Int32 is a type provided by the .Net framework class while int is an alias name for int32 in the C# programming language. There is no other difference between int and int32.

12. Differentiate value type and reference type

The major differences between value type and reference type are as follows
  • A value type holds the actual data directly within the memory location while a reference type holds a pointer that contains the address of another memory location that has actual data.
  • A value type stores its contents on the stock memory while a reference type stores its contents on the heap memory.
  • It will copy the value directly when assigning a value type variable to another variable while it doesn’t copy the value when assigning a reference type variable to another but it creates a second copy of the reference.
  • The examples for value types are predefined data types, enums, and structures. Examples of reference types are classes, objects, indexes, interfaces, and arrays.

13. Differentiate managed and unmanaged code

  • The main difference between managed and unmanaged code is managed by CLR while unmanaged code is not managed by CLR.
  • .Net framework is a must for execution in managed code while unmanaged code does not require a .Net framework for execution.
  • Memory management will be done through garbage collection while the runtime environment takes care of memory management in unmanaged code.

14. Explain about MSIL

  • MSIL stands for Microsoft Intermediate Language which presents instructions for calling methods, storing and initializing values, memory handling, and exception handling.
  • The instructions provided by MSIL are platform-independent and generated by the Language-specific compiler from the source code.
  • JIT (Just-In-Time) compiler compiles the MSIL code into machine code based on the needs.

15. What is role-based security in .Net?

Role-based security is used to implement security features in .Net based on the rules allocated to the users of the organization. The authorization of users assigned with their roles in the organization. Likewise, Windows have role-based access to users, guests, and administrator.

16. What are the various types of assembly?

  • Assemblies are divided into two major types Private Assembly and Shared or Public Assembly. Private Assembly is accessible only to the application.
  • Users need to copy this private assembly separately to all the application folders wherever he wants to use that assembly as they can’t access the private assembly unless they copied them.
  • Whereas, the public or shared assembly can be shared by multiple applications. It doesn’t require copying separately into all application folders. Only one copy is enough at the system level and we can use the same copy for multiple applications.
  • It will be installed in the Global Assembly Cache (GAC).

17. List out the order of events in a page life cycle.

The order of events for a successful page rendering contains the following eight events
  • Page_PreInit
  • Page_Init
  • Page_InitComplete
  • Page_PreLoad
  • Page_Load
  • Page_LoadComplete
  • Page_PreRender
  • Render

18. Define Garbage Collector

  • Garbage Collector is used to freeing up the unused code objects in the memory and the memory heap is partitioned into 3 generations.
  • Generation 0 holds short-lived objects, Generation 1 stores medium-lived objects, and Generation 2 is for long-lived objects.
  • Collection of garbage means checking for objects in the generations of the managed heap that are no longer used by the application. It performs the required operations to reclaim the memory. It must perform a collection to free up some memory space.
  • In the garbage collection process, the list of live objects is recognized, references are updated for the compacted objects, and the memory space occupied by dead objects will be recollected. The remaining objects are moved to an older segment and System.GC.Collect() is the method used to perform the garbage collection process in the .Net framework.

19. Define Caching

Caching is used to store the data temporarily in the memory for accessing from memory easily by an application instead of searching for it in the original location. It improves the speed and performance efficiency of an application. There are three types of caching namely page caching, data caching, and fragment caching.

20. How to apply themes to ASP.Net applications?

We can apply themes to ASP.Net applications with the code of the ‘web.config’ file. Following is the detailed code <configuration> <system.web> <pages theme = “windows”/> </system.web> </configuration>

21. What are the differences between ASP and ASP.Net?

  • ASP stands for Active Server Page that uses VBScript and the codes of ASP interpreted during the execution time.
  • Whereas, ASP.Net uses .Net languages such as VB.Net or C# that are compiled to MSIL. ASP is the server-side technology Microsoft used to create web pages.
  • ASP.Net is also developed by Microsoft for developing dynamic web applications. ASP is partially based on OOPs but ASP.Net is completely based on Object-Oriented Programming.
  • ASP has no in-built support for XML whereas, ASP.Net has full XML support for easy data exchange. ASP uses ADO technology and ASP.Net utilizes ADO.Net technology for connecting and working with databases.

22. What is MVC?

  • MVC stands for Model View Controller which is an architecture used to build .Net applications. There are three main logical components in the MVC such as the model, the view, and the controller.
  • The model holds the data and its related logic. It handles the object storage and retrieval process from the databases to an application.
  • The view is used to handle the UI part of an application. They will get information from the model for their display.
  • The controller is used to handle the user interactions and figure out the information for the user input and render the final output.

23. Define cross-page posting.

  • The data will be stored on the same page when we click on a submit button on a web page. If the data is stored on a different page and linked to the current page, then it is known as a cross-page posting.
  • It is achieved by ‘POSTBACKURL’ property. The FindControl method will be used to get the values that are posted on the particular webpage.

24. List out the security controls of ASP.Net?

The following five security controls are available in the ASP.Net
  • <asp: Login> provides a login capability that allows the users to enter their credentials with a user ID and password fields.
  • <asp: LoginName> is used to display the user’s name who are logged-in
  • <asp: LoginView> is providing a variety of views depending on the template that has been selected by the user.
  • <asp: LoginStatus> is used to check whether the user is authenticated or not.
  • <asp: PasswordRecovery> is used to send an email to a user while resetting the password.

25. Define MIME in .Net

  • MIME is the abbreviation for Multipurpose Internet Mail Extensions. It is the extension of the e-mail protocol that lets users utilize the protocol for exchanging files across emails easily.
  • Servers insert the MIME header at the beginning of the web transmission to define the MIME transactions.
  • Then the clients utilize the header for selecting an appropriate ‘player’ for the type of data that the header denotes.
  • Some of the players are developed into the web browser.

Dot Net Interview Questions and Answers for Experienced

26. What are the uses of .Net core?

.Net Core is the newest version of the .Net framework and it is used for the following things
  • Server application development is enhanced with .Net Core as it helps in running on various operating systems like Mac, Windows, and Linux. Developer can write libraries and applications in C#, VB.Net, and F# on both runtimes using this .Net Core.
  • Cloud application and large enterprise application modification into microservices are easy with .Net Core.
  • Cross-development between WPF, UWP, and Windows Forms is supported by .Net Core.
  • Microservices that allow cross-platform services are supported by .Net Core including services developed with .Net framework, Java, Ruby, etc.
  • .Net Core has numerous features like lightweight, modularity, and flexibility making easy deployment of .Net Core applications in containers and these containers will be deployed in any operating system like Linux, Cloud, or Windows.

27. Explain the purpose of webHostBuilder()

  • WebHostBuilder() is a function used for HTTP pipeline creation with webHostBuilder.use() method that is in webHostBuilder.Build() using the builder pattern.
  • It is provided by Microsoft.AspNet.Hosting namespace. The purpose of the build() method is to build necessary services and a Microsoft.AspNetCore.Hosting.IWebHost for hosting a web application.

28. Define CoreFx

  • CoreFx is the collection of class library implementations for .Net Core and it contains types, file systems, console, JSON, async, XML, etc.
  • It is platform-neutral code that can be shared over all the platforms.
  • It is implemented in the form of a single portable assembly that can be used on all operating systems such as Windows, Linux, and macOS.

29. Define Transfer-encoding

  • Transfer-encoding is used to transfer the payload body which is the information part of the data sent in the HTTP message body to the user.
  • It is a hop-by-hop header applied not to a resource but to a message between two nodes. Every multi-node connection segment uses various Transfer-encoding values.
  • It will be set to “Chunked” by specifying that the Hypertext Transfer Protocol mechanism for encoding data transfer is initiated in which data has been sent in a form of chunks.
  • It is helpful when the amount of data sent to the client is larger and the total size of the response will not be known until the completion of request processing.

30. Define Universal Windows Platform (UWP) apps in .Net Core

Universal Windows Platform (UWP) is one of the methods used for creating client applications for Windows. It will make use of WinRT API to provide a powerful user interface (UI) and advanced asynchronous features for devices with internet connections.

31. What are the features of UWP?

The main features of UWP (Universal Windows Platform) are as follows
  • Secure: UWP apps specify which resources of device and data are accessed by them.
  • Common API on all devices that runs on Windows 10 is possible.
  • UWP allows to use of the specific capabilities of the device and adapts the user interface (UI) to various device screen sizes, resolutions, and DPI (Dots Per Inches).
  • Microsoft Store has UWP for all specified devices that run on Windows 10
  • UWP can be installed and uninstalled apps without any risk to the machine or incurring “machine rot”.
  • UWP’s engaging: It uses live titles, push notifications, and user activities that interact with the Timeline of Windows and “Cortana’s Pick up where I left off” for engaging users.
  • UWP can be programmable in C++, C#, JavaScript, and VB. For User Interface will be used in WinUI, XAML, DirectX, or HTML.

32. What are the major components of .Net Core?

  • The .Net Core is framed with four major components namely CLI tools, Roslyn a .Net Compiler Platform, CoreFx, and CoreCLR.
  • CLI Tools: Common Line Interface tools are used for developing, building, executing, restoring, and deploying packages.
  • It has the capability to build console applications and class libraries that can be executed in the entire .Net Framework.
  • It will be installed with .Net Core SDK for the selected platforms and it doesn’t need separate installation on the development machine.
  • It can be verified for the proper CLI Installation by typing dotnet on the command prompt of Windows.
  • Roslyn is the .Net compiler platform which is a set of open-source language compilers with code analysis API for the C# and VB.Net programming languages.
  • It exposes modules for dynamic compilation to Common Intermediate Language (CIL), code emission, and syntactic and semantic code analysis.
  • CoreFx is a set of framework libraries that contains the new BCL (Base Class Library) like System.*, System.Xml, and System.Collections.
  • CoreCLR is the JIT (Just-In-Time) based CLR (Common Language Runtime) which is the runtime implementation that runs cross-platform with the GC, Native Interop, and RyuJIT.

33. Explain about Middleware in .Net Core

  • Middleware is used to handle requests and responses of the software assembled into an application pipeline.
  • Each component will select the request and that should be transferred to the next component within the pipeline and carries out work before and after the component within the pipeline.
  • The developer can have a middleware for user authentication, another one for serving static files like JavaScript, images, CSS files, and another one for handling errors, etc.
  • Middleware can be built-in into the .Net Core Framework that can be added by NuGet packages.
  • These middleware components are developed as a part of the configure method’s application startup class.
  • In the ASP.Net Core Application, these configuration methods will set up a request processing pipeline. It consists of a sequence of request delegates that are known one after another.
  • Usually, every middleware can be able to handle the incoming requests and passes the responses to the next middleware for processing.
  • A middleware component can take the decision of not calling the next middleware in the pipeline. It is known as short-circuiting the pipeline or terminating the request pipeline.
  • This process will be very helpful as it removes unnecessary work. If the request is made for a static file like a CSS file, JavaScript file, or Image file, the middleware process and serve the request and short-circuit the remaining pipeline.

34. What is Explicit Compilation?

  • Explicit Compilation is also known as Ahead of Time Compilation which is the process of compiling a high-level language into a low-level language during the development time that is, before program execution. AOT compilation avoids or reduces the workload during the runtime.
  • It provides faster startup time for large applications as most of the code executes on startup. It requires more amount of disk space and memory or virtual address space to handle both IL (Intermediate Language) and Precompiled images.
  • The JIT (Just-In-Time) compiler will not do a lot of work like disk I/O actions that are expensive.
  • The AOT will convert the upper-level language into object code during the program execution and they are designed for ensuring whether the CPU will understand and convert line-by-line code before doing interaction with it.
  • The explicit compilation happens only once at the build-time and it doesn’t require shipping the HTML templates and the Angular compiler into the bundle.
  • The score code generated can start executing immediately after it and it has been downloaded into the browser.
  • The AOT compilation will turn the HTML template into the executable code fragment and it will analyze and compile the templates statically during the development time.

35. What are the benefits of AOT compilation?

AOT Compilation that is also referred to as Explicit Compilation has the following benefits
  • Application size is smaller as the compiler itself isn’t shipped and unused features can be deleted.
  • Templates the parse errors that are identified previously during the execution time
  • Security is high and it doesn’t require dynamically evaluating templates
  • Rendering of a component is faster and more efficient as it has pre-compiled templates
  • For AOT compilation, the tools are needed to accomplish it automatically in the development process.

36. Define MEF

  • The MEF stands for Managed Extensibility Framework is a library used for developing extensible and lightweight applications.
  • It allows application developers to use extensions without the requirement for configuration.
  • It enables extension developers to easier code encapsulation for avoiding fragile hard dependencies.
  • MEF let users reuse the extensions within applications and across the applications. It is an integral part of .Net Framework 4 for improving the maintainability, testability, and flexibility of large applications.

37. Explain about CoreRT

  • CoreRT is the native runtime for the compilation of .Net and it is the part of the new .Net Native that is released in April 2014.
  • It is not a virtual machine and it doesn’t have the facility of generating and executing the code on the fly as it is not contained JIT.
  • It has the ability for RTTI (Run-Time Type Identification) and reflection with the GC (Garbage Collector). The type system of the CoreRT is structured in a way that metadata identifies unused application code.

38. Explain MSBuild in the .Net Core

  • MSBuild is the open-source development platform for Visual Studio and Microsoft and it is a build tool used for automating the software product development process with source code compilation, testing, packaging, deployment, and document generation.
  • Using MSBuild, we can build Visual Studio projects and solutions without the need of installing the Visual Studio IDE (Integrated Development Environment).
  • In the UWP (Universal Windows Platform) app, if the user opens the folder named project, they will get to see both files namely project.json and *.csproj. If they open the previous Console Application in .Net Core, they will get to see project.json and *.xproj.

39. Explain MDI and SDI

  • MDI stands for Multiple Document Interface which allows the developer to open multiple windows and it will have one parent window with many child windows.
  • The components are shared from the parent window like menubar and toolbar.
  • SDI stands for Single Document Interface that opens each document in a separate window and each window has its own components like toolbar, menubar, etc and it is not constrained to the parent window.

40. What are the various parts of the Assembly?

Following are the different parts of the Assembly:
  • Manifest: Each static dynamic assembly contains a data collection to provide details about how the elements in the assembly related to each other. An Assembly manifest consists of complete metadata needed for specifying the version requirements and security identities of an assembly. It defines the assembly scope to resolve references to classes and other resources. It will be stored in either a standalone PE (Portable Executable) file that contains only assembly manifest information or in a PE file (.exe or .dll) with MSIL code.
  • Type Metadata: It gives additional information like types, type names, method names, etc about the contents of an assembly. It will be automatically generated by the compiler from the source files and the compiler will embed this metadata within the target output files like .exe or .dll or .netmodule.
  • MSIL: Microsoft Intermediate Language is a code that implements the types and it includes instructions to load, store, initialize, and call the methods on objects. It consists of instructions for control flow, arithmetic and logical operations, direct memory access, and exception handling. During the execution time, the JIT (Just-In-Time) compiler of CLR (Common Language Runtime) translates the MSIL code into native code for the operating system.
  • Resources: They can be a list of related files such as .jpg or .bmp files. These resources are static which means they do not change during the execution time and they are not executable things.

41. What is the role of SQL Scripts in the .Net Core?

SQL Scripts are useful for debugging and deploying migrations to a production database. It can be used for reviewing the accuracy of data to be tuned to fit the production database requirement in the future enhancement of .Net Core applications.

42. Define IGCToCLR Interface

IGCToCLR Interface is used as passed an argument to the InitializeGarbageCollector() function and it is used for runtime interaction. It consists of a lot of built-in methods like RestartEE() and SuspendEE().

43. What are the differences between .Net Core and Mono?

  • .Net Core is the subset implementation of the .Net Framework developed by Microsoft. Mono is the complete implementation of the .Net Framework for Linux, iOS, and Android developed by Xamarin.
  • .Net Core allows the developers to build web applications and console applications. Mono allows the developers to build various application types available in .Net Framework including mobile apps, GUI-enabled desktop apps, etc.
  • .Net Core doesn’t have the in-built capacity to be compiled into WebAssembly-compatible packages. Mono has an in-built capacity to be compiled into WebAssembly-compatible packages.
  • .Net Core is not for gaming app development. The developer can only build a text-based adventure or relatively basic browser-based game using .Net Core. Mono is intended for game development and the games will be developed using the Unity gaming engine that supports Mono.

44. Differentiate .Net Core and .Net Framework

Features .Net Core .Net
Compatibility .Net Core works based on the principle of “build once, run anywhere”. It is cross-platform with various operating systems like Linux, macOS, and Windows. It is compatible with the Windows IS only and even though, it was developed for supporting software and applications on all operating systems.
Installation It is cross-platform and it is packaged and installed independently of the OS It is installed as a single package for Windows OS.
Application Models .Net Core doesn’t support the development of desktop applications and focuses more on the Windows mobile, web, and Windows Store. It is used to develop both desktop and web apps. It is also supporting windows forms and WPF application developments.
Performance and Scalability It offers high performance and scalability to the applications. The performance and scalability of applications are less compared than .Net Core.
Microservices and Rest Services Support .Net Core supports in developing and deploying the microservices and the user needs to create a REST API for its implementations. .Net doesn’t support the development and implementation of microservices but it supports REST API services.
Packaging and Shipping It is shipped as a set of Nugget packages The libraries of .net packed and shipped all at once.
Android Development It supports open-source mobile app platforms like Xamarin through .Net Standard Library. The developers can use the tools of Xamarin for configuring the mobile apps for particular mobile device developments using iOS, Android, and Windows phones. It doesn’t support the development of mobile apps.
CLI Tools It offers lightweight editors with command-line tools for supporting all the platforms. .Net Framework is heavy for CLI (Command Line Interface) and developers can prefer to work on the lightweight CLI.
Deployment Model The updated version of .Net Core gets facilitated on one machine at a time that gets updated in new folders or directories of the existing application without affecting it. It has a very good flexible deployment model. If the updated version of the .Net Framework is released, it is deployed on the internet information server at first.

45. Write a program in ASP.Net to calculate the addition of two numbers?

Step 1: Create a new ASP.Net Core Project “CalculateSum” in Open Visual Studio 2015. For this go to File 🡪 New 🡪 Project. Select the option Web in Left Pane and go for the option ASP.Net Core Web Application (.Net Core) under the central pane. Edit the project name as “CalculateSum” and click ok. Step 2: In the template window, select Web Application and set the authentication to “No Authentication” and click ok. Step 3: Open “Solution Explorer” and give right-click on the folder “Home” then click on Add New Item. The MVC View Page Template is required to select under the ASP.Net section and rename as “sampleaddition.cshtml” and click Add Button. Step 4: Open addition.cshtml and write the following code. @{ ViewBag.Title = “Addition Page”; } <h1>Welcome to Addition Page</h1> <form asp-controller=”Home” asp-action=”add” method=”post”> <span>Enter First Number: </span> <input id=”Text1″ type=”text” name=”txtFirstNum” />  <br /><br /> <span>Enter Second Number: </span> <input id=”Text2″ type=”text” name=”txtSecondNum” />  <br /><br /> <input id=”Submit1″ type=”submit” value=”Add” /> </form> <h2>@ViewBag.Result</h2> Here, we have created a simple form that holds two text boxes and a single Add button. The text boxes are named as txtFirstNum and txtSecondNum. It can be accessed the textboxes using <form asp-controller = “Home” asp-action = “add” method = “post”> in the controller page. The form will indicate the submission and they will be moved to HomeController and the method add action will be executed. Step 5: Now open the HomeController.cs and write the following code in it. using System; using Microsoft.AspNetCore.Mvc; namespace CalculateSum.Controllers { public class HomeController : Controller { public IActionResult Index() { return View(); } public IActionResult About() { ViewData[“Message”] = “Application description page.”; return View(); } public IActionResult Contact() { ViewData[“Message”] = “Contact page.”; return View(); } public IActionResult Error() { return View(); } public IActionResult addition() { 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”); } } } Here, we have added two IAction Methods addition() and add(). It will return the addition view page and add() method that obtains input from the browser to be processed and the results will be stored in ViewBag. Now execute the program and you can see the following output on your screen.

46. Differentiate Custom Control and User Control

  • Custom Control inherits from the System.Windows.Controls.Control Class while User Control inherits from the system.Windows.Controls.
  • User Controls class. Custom Control is designed for single-application scenarios while User Control is designed for multi-application scenarios.
  • Custom Control introduces redundancy and maintenance problems if used in more than one application while User Control will be distributed without facing any problems associated with redundancy and maintenance.
  • Custom Control contains loosely coupled control concerning code and UI (User Interface) while User Control is tightly coupled control concerning code and UI.

47. Write a code to send an email from an ASP.Net application.

The following code is used to send emails from the ASP.Net application:
  • MailMessage mailMess = new MailMessage();
  • mailMess.Subject = “Sample Email”;
  • mailMess.Body = “Verify the sample mail.”;
  • SmtpMail.SmtpServer = “localhost”;
  • SmtpMail.Send (mailMess);
  • MailMessage and SmtpMail are pre-defined classes that are in System.Web.Mail namespace.

48. What are the designing principles used in .Net?

  • The designing principle used in .Net is known as SOLID which expands with the following principles.
  • Single Responsibility Principle (SRP)
  • Open-Closed Principle (OCP)
  • Liskov Substitution Principle (LSP)
  • Interface Segregation Principle (ISP)
  • Dependency Inversion Principle (DIP)
  • SRP (Single Responsibility Principle) in .Net means that each software module or class must have only one reason to change. In simple terms, each module or class should have only one responsibility to perform. These classes or modules will never change.
  • OCP (Open-Closed Principle) in .Net means that the software modules or classes must be open for extension but closed for modification. It means that the creation of a software module or class behavior changes without the need to edit or recompile the codes.
  • LSP (Liskov Substitution Principle) in .Net means that the child class objects should be able to replace parent class objects without compromising application integrity,. It is used for standardizing the messages exchanged between a development tool and a language server process.
  • ISP (Interface Segregation Principle) in .Net means that the client should not be forced to implement any methods that they are not using. There are some interfaces preferred based on groups of methods with each interface serving one submodule.
  • DIP (Dependency Inversion Principle) in .Net means that a high-level class should not depend upon a lower-level class. It must depend upon abstractions and these abstractions must not depend upon details but the details should depend upon abstractions.

49. Define PE file

PE is the abbreviation for Portable Executable. It is a derivative of the Microsoft Common Object File Format (COFF). They are windows executable and .exe or .dll files follow the PE file format and it contains the four major parts as follows
  • PF or COFF Headers that contain information regarding .exe or .dll file
  • CLR header contains information about CLR and Memory Management
  • CLR Data contains metadata of DDLs and MSIL code generated by compilers
  • Native image section consists of sections such as .data, .rdata, rsrc, .text, etc.

50. What are the types of JIT in .Net?

JIT (Just-In-Time) compiler in the CLR is taking care of code execution of .Net programs of various programming languages. This is to convert the code into machine code and it speeds up the execution of code and supports multiple platforms. Following are the three types of JIT compilers
  • Pre-JIT compiler: It compiles the source code into the machine code in one compilation cycle at the time of application deployment.
  • Normal JIT Compiler: The source code methods or classes are needed at the run-time that is compiled into the machine code and it is stored in the cache that is to be called in the future.
  • Econo JIT Compiler: Some methods are required only at the run-time for compiling through this compiler and they will not be stored for future use.

Conclusion The learning of .Net and .Net Core is useful for the learners to kick-start their career in web, web service, and web app development. We offer the job-centric and Best .Net Training in Chennai for global aspirants to reach their career goals easier and faster. Join us to explore the wide range of opportunities in .Net Development and prepare with this article that contains “.Net Interview Questions and Answers that will be helpful to ace the interview confidently.
Share on your Social Media

Just a minute!

If you have any questions that you did not find answers for, our counsellors are here to answer them. You can get all your queries answered before deciding to join SLA and move your career forward.

We are excited to get started with you

Give us your information and we will arange for a free call (at your convenience) with one of our counsellors. You can get all your queries answered before deciding to join SLA and move your career forward.