## Existing .NET article questions to include ## .NET Interview Questions for freshers #### 1. What is CTS? #### 2. Explain CLS. #### 3. What is JIT? #### 4. What is the difference between int and Int32? #### 5. Explain the differences between value type and reference type. #### 6. What is the difference between managed and unmanaged code? #### 7. Explain Microsoft Intermediate Language. #### 8. What is an assembly? #### 10. Explain the different types of assembly. #### 11. What is a garbage collector? #### 12. What is caching? #### 13. Explain MVC. #### 14. What is a delegate in .NET? #### 15. What is boxing and unboxing in .NET? #### 16. What is the use of manifest in the .NET framework? #### 17. What is the meaning of CAS in .NET? #### 18. What is the difference between an abstract class and an interface? #### 19. What are the types of memories supported in the .NET framework? #### 20. Explain localization and globalization. #### 21. What are the parameters that control the connection pooling behaviors? #### 22. What are MDI and SDI? #### 23. Explain the various parts of an Assembly. ##### (UPDATED ANSWER) The different parts of an assembly are: - **Manifest –** Every static or dynamic assembly holds a data collection that gives details about how the elements in the assembly relate to each other. 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. - **Type Metadata –** Metadata gives you additional information such as types, type names, method names, etc about the contents of an assembly. 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). - **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. During the runtime, the JIT(Just In Time) compiler of CLR(Common Language Runtime) converts the MSIL code into native code to the Operating System. - **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. ![](https://i.imgur.com/4QAmUcn.png) ## .NET Interview questions for experienced #### 9. Is ASP.NET different from ASP? If yes, explain how? #### 24. What is an EXE and a DLL? #### 25. Explain role-based security in .NET. #### 26. What is the order of the events in a page life cycle? #### 27. Can we apply themes to ASP.NET applications? #### 28. What is cross-page posting? #### 29. What are security controls available on ASP.NET? #### 30. What is MIME in .NET? #### 31. Explain different types of cookies available in ASP.NET? #### 32. What is the appSettings section in the web.config file? #### 33. Explain about major components of the .NET framework. ##### (NEWLY ADDED QUESTION) The major components .NET framework are given below: 1. **Common Language Runtime(CLR):** - It is an execution engine that runs the code and provides services that make the development process easier. - Services provided by CLR are memory management, garbage collection, type safety, exception handling, security, and thread management. It also makes it easier for designing the applications and components whose objects interact across the languages. - The programs written for the .NET Framework are executed by the CLR regardless of programming language. Every .NET Framework version is having CLR. 2. **Framework Class Library(FCL):** - It has pre-defined methods and properties to implement common and complex functions that can be used by .NET applications. 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):** - The Base Class Library(BCL) has a huge collection of libraries features and functions that are helpful in implementing various programming languages such as C#, F#, Visual C++, etc., in the .NET Framework. - BCL is divided into two parts. They are: 1. **User-defined class library:** It includes Assemblies. - *Assembly:* A .NET assembly is considered as the major building block of the .NET Framework. An assembly in the CLI(Common Language Infrastructure) is a logical unit of code, which is used for security, deployment, and versioning. Assembly can be defined in two forms namely Dynamic Link Library(.dll) and executable(.exe) files. When compilation of the .NET program takes place, metadata with Microsoft Intermediate Language(MSIL) will be generated and will be stored in a file called Assembly. 2. **Predefined class library:** It contains namespace. - *Namespace:* It is the collection of pre-defined methods and classes that are present in the .Net Framework. A namespace can be added to a .NET program with the help of "using system", where using represents a keyword and system represents a namespace. 4. **Common Type System(CTS):** - CTS specifies a standard that will mention which type of data and value can be defined and managed in memory during runtime. - It will make sure that programming data defined in different languages should interact with each other for sharing the information. For example, in VB.NET we define datatype as integer, while in C# we define int as a data type. - It can be used to prevent data loss when you are trying to transfer data from a type in one language to its equivalent type in another language. 5. **Common Language Specification (CLS):** - Common Language Specification (CLS) is a subset of CTS and defines a set of rules and regulations to be followed by every .NET Framework's language. - A CLS will support inter-operability or cross-language integration, which means it provides a common platform for interacting and sharing information. For example, every programming language(C#, F#, VB .Net, etc.) under the .NET framework has its own syntax. So when statements belonging to different languages get executed, a common platform will be provided by the CLS to interact and share the information. ![](https://i.imgur.com/hF6hJhR.png) #### 34. How does the .NET framework work? ##### (NEWLY ADDED QUESTION) - .NET framework-based applications that are written in supportive languages like C#, F#, or Visual basic are compiled to Common Intermediate Language (CIL). - Compiled code is stored in the form of an assembly file that has a .dll or .exe file extension. - When the .NET application runs, Common Language Runtime (CLR) takes the assembly file and converts the CIL into machine code with the help of the Just In Time(JIT) compiler. - Now, this machine code can execute on the specific architecture of the computer it is running on. ![](https://i.imgur.com/NHhGimH.png) ## References All the references should be included. ## MCQ's on .NET All the questions should be included. # .NET Core Interview Questions ## .NET Framework .NET framework provides an environment for creating, running, debugging, and deploying the application by using tools and functionalities like classes, and APIs. It is developed by Microsoft. This framework will use object-oriented programming. 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. ## .NET Core Framework .NET Core is a newer version of the .NET framework and it is a general-purpose, cost-free, open-source development platform developed by Microsoft. .NET Core is a cross-platform framework that runs an application on different operating systems such as Windows, Linux, and macOS operating systems. This framework can be used to develop various kinds of applications like mobile, web, IoT, cloud, microservices, machine learning, game, etc. ### Characteristics of .NET Core - **Free and open-source:** .NET Core source code project can be obtained from Github. It is free and licensed under the MIT and Apache licenses. - **Cross-platform:** .NET Core is supported by different operating systems like Windows, macOS, and Linux. - **Sharable:** A single consistent API model that is written in .NET Standard will be used by .NET Core and is common for all the .NET applications. The same library or API can be used on multiple platforms with different languages. - **Friendly:** The .NET Core is compatible with .NET Framework, Mono, and Xamarin, through .NET Standard. It also supports working with different Web frameworks and libraries such as Angular, React, and JavaScript. - **Fast:** .NET Core 3.0 is faster compared to the .NET Framework, .NET Core 2.2 and previous versions. It is also much faster than other server-side frameworks like Node.js and Java Servlet. ## Scope of .NET It is used to create and run different applications like web, mobile, desktop, games, etc. Applications developed using .NET can run on many operating systems such as linux, macOS or windows, using different implementations of .NET. .NET is used by a lot of companies like Accenture, TerraCycle Inc. etc due to it's feature of scalable architecture. ## .NET Core Interview Questions ### .NET Core Interview Questions for Freshers #### 1. What is .NET core? .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. It consists of important features like cross-platform, sharable library, etc., that are necessary for running a basic .NET Core application. The remaining features are supplied in the form of NuGet packages, that can be added to your application according to your needs. Like this we can say, the .NET Core will boost up the performance of an application, decreases the memory footprint, and becomes easier for maintenance of an application. It follows the modular approach, so instead of the entire .NET Framework installation, your application can install or use only what is required. #### 2. What is Dot NET Core used for? - .NET Core is useful in the server application creations, that run on various operating systems like Windows, Mac, and Linux. Using this, developers can write libraries as well as applications in C#, F#, and VB.NET in both runtimes. - Generally, it is used for cloud applications or for modifying large enterprise applications into microservices. - .NET Core 3.0 supports cross-development between WPF, UWP, and Windows Forms. - .NET Core supports microservices, which permits cross-platform services to work with the .NET Core framework including services developed with .NET Framework, Ruby, Java, etc. - .NET Core’s features like lightweight, modularity, and flexibility make it easier to deploy .NET Core applications in containers. These containers can be deployed on any platform, Linux, cloud, and Windows. #### 3. What are C# and F#? C# is a general-purpose and object-oriented programming language from Microsoft that runs on the .NET platform. It is designed for CLI(Common Language Infrastructure), which has executable code and a runtime environment that allows for the usage of different high-level languages on various computer platforms and architectures. It is mainly used for developing web applications, desktop applications, mobile applications, database applications, games, etc. F# is an open-source, functional-first, object-oriented and, cross-platform programming language that runs on a .NET platform and is used for writing robust, succinct, and performant code. We can say that F# is data-oriented because here code involves transforming data with functions. It is mainly used in making scientific models, artificial intelligence research work, mathematical problem solving, financial modeling, GUI games, CPU design, compiler programming, etc. #### 4. 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. ![](https://i.imgur.com/eRwPMmE.png) Here, various programming languages will be compiled by respective compilers(Roslyn can compile both C# and VB code as it includes C# and VB compilers) and Common Intermediate Language(CIL) code will be generated. When the application execution begins, this CIL code is compiled into native machine code by using a JIT compiler included within CoreCLR. This CoreCLR is supported by many operating systems such as Windows, Linux, etc. #### 5. What is the purpose of webHostBuilder()? WebHostBuilder function is used for HTTP pipeline creation through `webHostBuilder.Use()` chaining all at once with `WebHostBuilder.Build()` by using the builder pattern. This function is provided by `Microsoft.AspNet.Hosting namespace`. The Build() method's purpose is building necessary services and a `Microsoft.AspNetCore.Hosting.IWebHost` for hosting a web application. #### 6. What is Zero Garbage Collectors? Zero Garbage Collectors allows you for object allocation as this is required by the Execution Engine. Created objects will not get deleted automatically and theoretically, no longer required memory is never reclaimed. 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. #### 7. What is CoreFx? 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. #### 8. What is the IGCToCLR interface? IGCToCLR interface will be passed as an argument to the InitializeGarbageCollector() function and it is used for runtime communication. It consists of a lot of built-in methods such as RestartEE(), SuspendEE(), etc. #### 9. What is the use of generating SQL scripts in the .NET core? 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. #### 10. Explain about types of Common Type System(CTS). Common Type System(CTS) standardizes all the datatypes that can be used by different programming languages under the .NET framework. CTS has two types. They are: 1. **Value Types:** They contain the values that are stored on a stack or allocated inline within a structure. They are divided into : - Built-in Value Types - It includes primitive data types such as Boolean, Byte, Char, Int32, etc. - User-defined Value Types - These are defined by the user in the source code. It can be enumeration or structure. - Enumerations - It is a set of enumerated values stored in the form of numeric type and are represented by labels. - Structures - It defines both data(fields of the structure) and the methods(operations performed on that data) of the structure. In .NET, all primitive data types like Boolean, Byte, Char, DateTime, Decimal, etc., are defined as structures. 3. **Reference Types:** It Stores a reference to the memory address of a value and is stored on the heap. They are divided into : - Interface types - It is used to implement functionalities such as testing for equality, comparing and sorting, etc. - Pointer types - It is a variable that holds the address of another variable. - Self-describing types - It is a data type that gives information about themselves for the sake of garbage collectors. It includes arrays(collection of variables with the same datatype stored under a single name) and class types(they define the operations like methods, properties, or events that are performed by an object and the data that the object contains) like user-defined classes, boxed value types, and delegates(used for event handlers and callback functions). ![](https://i.imgur.com/xxX4mTj.png) #### 11. Give the differences between .NET Core and Mono? | .NET Core | Mono | | ------ | ------ | | .Net Core is the subset of implementation for the .NET framework by Microsoft itself. | 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. | | .NET Core does not have the built-in capability to be compiled into WebAssembly-compatible packages. | Mono has 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.| #### 12. What is Transfer-encoding? Transfer-encoding is used for transferring the payload body(information part of the data sent in the HTTP message body) to the user. It is a hop-by-hop header, that is applied not to a resource itself, but to a message between two nodes. Each multi-node connection segment can make use of various Transfer-encoding values. Transfer-encoding is set to "Chunked" specifying that Hypertext Transfer Protocol's mechanism of Chunked encoding data transfer is initiated in which data will be sent in a form of a series of "chunks". This 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. #### 13. Whether ‘debug’ and ‘trace’ are the same? 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. #### 14. What is MSBuild in the .NET Core? 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. #### 15. What are Universal Windows Platform(UWP) Apps in .Net Core? Universal Windows Platform(UWP) is one of the methods used to create client applications for Windows. UWP apps will make use of WinRT APIs for providing powerful UI as well as features of advanced asynchronous that are ideal for devices with internet connections. **Features of UWP apps:** - 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. ### .NET Core Interview Questions for Experienced #### 1. Explain about .NET Core Components. The .NET Core Framework is composed of the following components: ![](https://i.imgur.com/gVIWicX.png) - **CLI Tools:** Command Line Interface(CLI) tools is a cross-platform tool for developing, building, executing, restoring packages, and publishing. It is also capable of building Console applications and class libraries that can run on the entire .NET framework. It is installed along with .NET Core SDK for the selected platforms. So it does not require separate installation on the development machine. We can verify for the proper CLI installation by typing `dotnet` on the command prompt of Windows and then pressing Enter. If usage and help-related texts are displayed, then we can conclude that CLI is installed properly. - **Roslyn(.NET Compiler platform):** It is a set of open-source language compiler and also has code analysis API for the C# and Visual Basic (VB.NET) programming languages. Roslyn exposes modules for dynamic compilation to Common Intermediate Language(CLI), syntactic (lexical) and semantic code analysis, and also code emission. - **CoreFX:** CoreFX is a set of framework libraries. It consists of the new BCL(Base Class Library) i.e. `System.*` things like `System.Xml`, `System.Collections`, etc. - **CoreCLR:** A JIT(Just In Time) based CLR (Command Language Runtime). CoreCLR is the runtime implementation that runs on cross-platform and has the GC, RyuJIT, native interop, etc. #### 2. What is middleware in .NET core? - Middleware is software assembled into an application pipeline for request and response handling. Each component will choose whether the request should be passed to the next component within the pipeline, also it can carry out work before and after the next component within the pipeline. - For example, we can have a middleware component for user authentication, another middleware for handling errors, and one more middleware for serving static files like JavaScript files, images, CSS files, etc. - It can be built-in into the .NET Core framework, which can be added through NuGet packages. These middleware components are built as part of the configure method's application startup class. In the ASP.NET Core application, these Configure methods will set up a request processing pipeline. It contains a sequence of request delegates that are called one after another. - Normally, each middleware will handle the incoming requests and passes the response to the next middleware for processing. A middleware component can take the decision of not calling the next middleware in the pipeline. This process is known as short-circuiting the pipeline or terminating the request pipeline. This process is very helpful as it avoids unnecessary work. For example, if the request is made for a static file such as a CSS file, image, or JavaScript file, etc., these static files middleware can process and serve the request and thus short-circuit the remaining pipeline. ![](https://i.imgur.com/IzsGMMJ.png) Here, there are three middlewares are associated with an ASP.NET Core web application. They can be either middleware provided by the framework, added through NuGet, or your own custom middleware. The HTTP request will be added or modified by each middleware and control will be optionally passed to the next middleware and a final response will be generated on the execution of all middleware components. #### 3. Differentiate .NET Core vs .NET framework. | Features | .NET Core | .NET framework | | ------ | ------ | ------ | | **Compatibility** | It works based on the principle of “build once, run anywhere”. It is cross-platform, so it is compatible with different operating systems such as Linux, Windows, and Mac OS. | This framework is compatible with the Windows operating system only. Even though, it was developed for supporting software and applications on all operating systems. | | **Installation** | 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. | | **Application Models** | It does not support developing the desktop application and it focuses mainly on the windows mobile, web, and windows store.| It is used for developing both desktop and web applications, along with that it also supports windows forms and WPF applications. | | **Performance and Scalability** | It provides high performance and scalability. | It is less effective compared to .Net Core in terms of performance as well as scalability of applications. | | **Support for Micro-Services and REST Services** | It supports developing and implementing the micro-services and the user is required to create a REST API for its implementation. | It does not support the microservices' development and implementation, but it supports REST API services.| | **Packaging and Shipping** | 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. | | **Android Development** | 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. | It does not support the development of mobile applications. | | **CLI Tools** | For all supported platforms, it provides lightweight editors along with command-line tools. | This framework is heavy for CLI(Command Line Interface) and developers usually prefer to work on the lightweight CLI.| | **Deployment Model** | Updated version of the .NET Core gets initiated 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. | When the updated version is released, it is deployed only on the Internet Information Server at first. | #### 4. Explain Explicit Compilation (Ahead Of Time compilation). - Ahead-of-time(AOT) compilation is the process of compiling a high-level language into a low-level language during build-time, i.e., before program execution. AOT compilation reduces the workload during run time. - AOT provides faster start-up time, in larger applications where most of the code executes on startup. But it needs more amount of disk space and memory or virtual address space to hold both IL(Intermediate Language) and precompiled images. In this case, the JIT(Just In Time) Compiler will do a lot of work like disk I/O actions, which are expensive. - The explicit compilation will convert the upper-level language into object code on the execution of the program. Ahead of time(AOT) compilers are designed for ensuring whether the CPU will understand line-by-line code before doing any interaction with it. - Ahead-of-Time (AOT) compilation happens only once during build time and it does not require shipping the HTML templates and the Angular compiler into the bundle. The source code generated can begin running immediately after it has been downloaded into the browser, earlier steps are not required. The AOT compilation will turn the HTML template into the runnable code fragment. AOT will analyze and compile our templates statically during build time. ![](https://i.imgur.com/vUC6TEo.png) **Benefits of AOT compilation:** - Application size is smaller because the Compiler itself isn’t shipped and unused features can be removed. - Template the parse errors that are detected previously(during build time) - Security is high (not required to dynamically evaluate templates) - Rendering of a component is faster (pre-compiled templates) - For AOT compilation, some tools are required to accomplish it automatically in the build process. #### 5. What is MEF? The MEF(Managed Extensibility Framework) is a library that is useful for developing extensible and lightweight applications. It permits application developers for using extensions without the need for configuration. It also allows extension developers for easier code encapsulation and thus avoiding fragile hard dependencies. MEF will let you reuse the extensions within applications, as well as across the applications. It is an integral part of the .NET Framework 4. It improves the maintainability, flexibility, and testability of large applications. #### 6. In what situations .NET Core and .NET Standard Class Library project types will be used? .NET Core library is used if there is a requirement to increase the surface area of the .NET API which your library will access, and permit only applications of .NET Core to be compatible with your library if you are okay with it. .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. #### 7. What is CoreRT? - CoreRT is the native runtime for the compilation of .NET natively ahead of time and it is a part of the new .NET Native (as announced in April 2014). - It is not a virtual machine and it does not have the facility of generating and running the code on the fly as it doesn't include a JIT. It has the ability for RTTI(run-time type identification) and reflection, along with that it has GC(Garbage Collector). - The type system of the CoreRT is designed in such a way that metadata for reflection is not at all required. This feature enables to have an AOT toolchain that can link away unused metadata and can identify unused application code. #### 8. What is .NET Core SDK? .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. #### 9. What is Docker? - Docker is an open-source platform for the development of applications, and also for shipping and running them. It allows for separating the application from the infrastructure using containers so that software can be delivered quickly. With Docker, you will be able to manage the infrastructure in the same ways you used to manage your applications. - It supports shipping, testing, and deploying application code quickly, thus reducing the delay between code writing and running it in production. - The Docker platform provides the ability of packaging and application execution in a loosely isolated environment namely container. The isolation and security permit you for running multiple containers at the same time on a given host. Containers are lightweight and they include every necessary thing required for running an application, so you need not depend on what is currently installed within the host. #### 10. What is Xamarin? - Xamarin is an open-source platform useful in developing a modern and efficient application for iOS, Android, and Windows with .NET. It is an abstraction layer used to manage the communication of shared code with fundamental platform code. - Xamarin runs in a managed environment that gives benefits like garbage collection and memory allocation. - Developers can share about 90% of their applications over platforms using Xamarin. This pattern permits developers for writing entire business logic in a single language (or reusing existing app code) but accomplish native performance, look and feel on each platform. The Xamarin applications can be written on Mac or PC and then they will be compiled into native application packages, like a .ipa file on iOS, or .apk file on Android. #### 11. How can you differentiate ASP.NET Core from .NET Core? .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". An application using the tools and libraries of ASP.NET Core is normally referred to as "ASP.NET Core Application", which in theory doesn't say whether it is built for .NET Framework or .NET Core. So an application of "ASP.NET Core" can be considered as a ".NET Core Application" or a ".NET Framework Application". #### 12. Write a program to calculate the addition of two numbers. The steps are as follows: 1. You need to create a new ASP.NET Core Project "CalculateSum". Open Visual Studio 2015, goto **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 on OK. 2. In the template window, select Web Application and set the Authentication into "No Authentication" and click on OK. 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. 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 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(); } 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"); } } } ``` 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: ![](https://i.imgur.com/wCKM759.png) ### 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. ### References * https://www.dotnettricks.com/learn/netcore * https://dotnetcoretutorials.com/ * https://www.tutorialspoint.com/dotnet_core/index.htm * https://www.youtube.com/watch?v=hy3ONCDLh-Y * https://www.youtube.com/watch?v=O_huuhKWqVA ### MCQ's on .NET Core #### 1. ______ is the latest version of .NET core as per 2021. - [x] a. .NET Core 3.1 - [ ] b. .NET Core 3.0 - [ ] c. .NET Core 3.5 - [ ] d. None of the above - Answer: a. .NET Core 3.1 #### 2. Docker is used for ______. - [ ] a. Developing the applications - [ ] b. Shipping the applications - [ ] c. Running the applications - [x] d. All of the above - Answer: d. All of the above #### 3. .NET Core framework is composed of ______. - [ ] a. CLI tools - [ ] b. Roslyn - [ ] c. CoreFX and CoreCLR - [x] d. All of the above - Answer: d. All of the above #### 4. What is the use of microservices? - [x] a. Mix technologies across the service boundary - [ ] b. Debugging - [ ] c. Creating and deploying a container - [ ] d. None of the above - Answer: a. Mix technologies across the service boundary #### 5. .NET core is ______. - [ ] a. Windows only - [x] b. Cross-platform - [ ] c. Linux only - [ ] d. MacOS only - Answer: b. Cross-platform #### 6. What is CoreFX? - [ ] a. Toolset for the development of applications - [ ] b. Compiler - [x] c. Foundational class libraries for .NET Core - [ ] d. Docker container - Answer: c. Foundational class libraries for .NET Core #### 7. What is included within CoreCLR? - [ ] a. Garbage Collector - [ ] b. JIT Compiler - [ ] c. Primitive data types - [x] d. All of the above - Answer: d. All of the above #### 8. What is Roslyn? - [x] a. .NET Compiler platform - [ ] b. Container - [ ] c. Library - [ ] d. None of the above - Answer: a. .NET Compiler platform #### 9. `System.Linq` namespace contains classes and interfaces that support ______. - [ ] a. use of a memory-mapped file - [x] b. queries that use LINQ(Language-Integrated Query) - [ ] c. to configure an assembly - [ ] d. immutable collections - Answer: b. queries that use LINQ(Language-Integrated Query) #### 10. Using which package we can share the libraries in .NET Core? - [x] a. NuGet package - [ ] b. LINQ - [ ] c. System - [ ] d. Dapper - Answer: a. NuGet package