Top 10 .NET Core Interview Questions and answer

Hello guys, Today I’m going to list out some interview questions that might be helpful for the .NET Core interview.

Below are questions and answers that will helps you.

 

1. How does.NET Core vary from the.NET Framework? What is it?

A free, open-source, and cross-platform framework called.NET Core may be used to create contemporary desktop, mobile, and online applications. It is the.NET Framework’s replacement, although it is intended to be more modular, lightweight, and scalable. .NET Core is compatible with Windows, Linux, and macOS, in contrast to the.NET Framework, which is exclusively accessible on Windows.

2.What are the advantages of using.NET Core while creating applications?

Using.NET Core for application development has several major advantages, some of them are as follows:

Cross-platform compatibility: Since.NET Core runs on Windows, Linux, and macOS, it is simple to create and deploy apps across these different operating systems.

High performance: JIT compilation and improved garbage collection are only two of the features that make.NET Core quick and effective.

Modular architecture:.NET Core is built with a lightweight runtime and a collection of libraries that may be used separately from one another.

Open-source:.NET Core is open-source, and a sizable developer community contributes to its development, making it simple to locate assistance and support.

3.What distinguishes.NET Core and.NET Standard from one another?

A set of APIs must be implemented in accordance with the.NET Standard in order for any.NET implementation to be compatible with it. Although.NET Core implements the.NET Standard, it also has extra APIs and functionality that are exclusive to.NET Core. In other words,.NET Core is a particular implementation of those APIs, whereas.NET Standard is a collection of APIs that may be utilised by various.NET implementations.

4.What distinguishes a.NET Core web application from a.NET Core console application?

A command-line programme that runs in a console window is referred to as a.NET Core console application. Usually, it receives input from the user and outputs something on the console. On the other hand, a.NET Core web application is a programme that runs on a web server and answers to HTTP requests from clients. In most cases, it contains of a number of controllers that process incoming requests and deliver results in different forms, such HTML, JSON, or XML.

5.Why is dependency injection necessary in.NET Core? What is dependency injection?

A design technique called dependency injection enables you to isolate the production of objects from their use. Dependency injection is used in.NET Core to handle dependencies between application components. This makes writing modular, tested, and maintainable programming simpler. Reducing coupling between various components of your programme with dependency injection makes it simpler to update or replace those components without impacting the rest of the system.

6.What is middleware and how does it function in ASP.NET Core?

Software that stands in between your application code and the web server is known as middleware in ASP.NET Core. It catches incoming requests, processes them, and then forwards them to the following piece of middleware or to the application code. Logging, authentication, caching, and routing are just a few of the duties that middleware may handle. The app is used to configure middleware. The Startup.cs file contains the UseMiddleware function.

7.Describe.NET Core.

An open-source, cross-platform, and modular framework for creating contemporary apps is called.NET Core. It is a runtime environment that consists of a collection of libraries, language compilers, and development tools that provide programmers the ability to build high-performance, scalable, and cloud-based apps supports several operating systems, such as Linux, macOS, and Windows.

8.With ASP.NET Core, what distinguishes ViewBag, ViewData, and TempData?

With ASP.NET Core, there are three different ways to transmit data from a controller to a view: ViewBag, ViewData, and TempData. The following are the key variations between these mechanisms:

ViewBag: A dynamic feature called ViewBag allows data to be sent as key-value pairs. The property name in the view may be used to retrieve the data.
ViewData: A key-value pair-passing object that resembles a dictionary. With the key name, the data is available in the view.
TempData: An object resembling a dictionary that permits

9.In.NET Core, how can we consume APIs or web services?

The HttpClient class, which is a component of the System.Net.Http namespace, may be used in.NET Core to consume an API or WebService. The following steps will show you how to use HttpClient in.NET Core to use an API or WebService:

Make an instance of the class HttpClient:

HttpClient client = new HttpClient();

Set the base address of the API or WebService:

client.BaseAddress = new Uri("http://example.com/api/");

Use the right HTTP method to call the API or WebService:

HttpResponseMessage response = await client.GetAsync("resource");

Read the substance of the reply:

string responseBody = await response.Content.ReadAsStringAsync();

In the end,Process the answer in accordance with the logic of your application.

10.Differences between the.NET Core AddScope, AddTransient, and Singleton scopes

Transient: Each time the service is accessed from the DI container, a new instance of it is generated.

Scoped : The scope of each request results in the creation of a fresh instance of the service. All of the components that are resolved inside the same scope utilise the same instance.

Singleton: During the duration of the application, only one instance of the service is created.

 

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories