The sun is setting on .NET Framework. From now on, .NET Core is king. New projects, be they web or desktop, should be started in .NET Core. Stay prepared for your next .NET Core Tech Interview with our list of top .NET Core interview questions and answers.
You could also find all the answers here π https://www.fullstack.cafe/.NET%20Core.
Answer:
The .NET Core platform is a new .NET stack that is optimized for open source development and agile delivery on NuGet.
.NET Core has two major components. It includes a small runtime that is built from the same codebase as the .NET Framework CLR. The .NET Core runtime includes the same GC and JIT (RyuJIT), but doesnβt include features like Application Domains or Code Access Security. The runtime is delivered via NuGet, as part of the ASP.NET Core package.
.NET Core also includes the base class libraries. These libraries are largely the same code as the .NET Framework class libraries, but have been factored (removal of dependencies) to enable to ship a smaller set of libraries. These libraries are shipped as System.*
NuGet packages on NuGet.org.
π Source: stackoverflow.com
Answer:
string
is an alias in C# for System.String
. So technically, there is no difference. It's like int
vs. System.Int32
.
As far as guidelines, it's generally recommended to use string
any time you're referring to an object.
string place = "world";
Likewise, it's generally recommended to use String
if you need to refer specifically to the class.
string greet = String.Format("Hello {0}!", place);
π Source: blogs.msdn.microsoft.com
Answer:
The .NET is a Framework, which is a collection of classes of reusable libraries given by Microsoft to be used in other .NET applications and to develop, build and deploy many types of applications on the Windows platform including the following:
- Console Applications
- Windows Forms Applications
- Windows Presentation Foundation (WPF) Applications
- Web Applications
- Web Services
- Windows Services
- Services-oriented applications using Windows Communications Foundation (WCF)
- Workflow-enabled applications using Windows Workflow Foundation(WF)
π Source: c-sharpcorner.com
Answer:
The .NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementations.
π Source: docs.microsoft.com
Answer:
To be simple:
- Mono is third party implementation of .Net Framework for Linux/Android/iOs
- .Net Core is Microsoft's own implementation for same.
π Source: stackoverflow.com
Answer:
-
Flexible deployment: Can be included in your app or installed side-by-side user- or machine-wide.
-
Cross-platform: Runs on Windows, macOS and Linux; can be ported to other OSes. The supported Operating Systems (OS), CPUs and application scenarios will grow over time, provided by Microsoft, other companies, and individuals.
-
Command-line tools: All product scenarios can be exercised at the command-line.
-
Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.
-
Open source: The .NET Core platform is open source, using MIT and Apache 2 licenses. Documentation is licensed under CC-BY. .NET Core is a .NET Foundation project.
-
Supported by Microsoft: .NET Core is supported by Microsoft, per .NET Core Support
π Source: stackoverflow.com
Answer:
-
The SDK is all of the stuff that is needed/makes developing a .NET Core application easier, such as the CLI and a compiler.
-
The runtime is the "virtual machine" that hosts/runs the application and abstracts all the interaction with the base operating system.
π Source: stackoverflow.com
Questions Details:
When would someone use one of these?
Answer:
Precision is the main difference.
- Float - 7 digits (32 bit)
- Double-15-16 digits (64 bit)
- Decimal -28-29 significant digits (128 bit)
As for what to use when:
-
For values which are "naturally exact decimals" it's good to use decimal. This is usually suitable for any concepts invented by humans: financial values are the most obvious example, but there are others too. Consider the score given to divers or ice skaters, for example.
-
For values which are more artefacts of nature which can't really be measured exactly anyway, float/double are more appropriate. For example, scientific data would usually be represented in this form. Here, the original values won't be "decimally accurate" to start with, so it's not important for the expected results to maintain the "decimal accuracy". Floating binary point types are much faster to work with than decimals.
π Source: blogs.msdn.microsoft.com
Answer:
Use that rule of thumb:
- If you found it in the Microsoft .NET Framework: it's managed.
- If you went poking around MSDN yourself, it's unmanaged.
Anything you've used P/Invoke calls to get outside of the nice comfy world of everything available to you in the .NET Framwork is unmanaged β and you're now responsible for cleaning it up.
π Source: stackoverflow.com
Answer:
When we compile our .NET code then it is not directly converted to native/binary code; it is first converted into intermediate code known as MSIL code which is then interpreted by the CLR. MSIL is independent of hardware and the operating system. Cross language relationships are possible since MSIL is the same for all .NET languages. MSIL is further converted into native code.
π Source: c-sharpcorner.com
Answer:
It is an isolation layer provided by the .NET runtime. As such, App domains live with in a process (1 process can have many app domains) and have their own virtual address space.
App domains are useful because:
- They are less expensive than full processes
- They are multithreaded
- You can stop one without killing everything in the process
- Segregation of resources/config/etc
- Each app domain runs on its own security level
π Source: stackoverflow.com
Answer:
CLR services
- Assembly Resolver
- Assembly Loader
- Type Checker
- COM marshalled
- Debug Manager
- Thread Support
- IL to Native compiler
- Exception Manager
- Garbage Collector
π Source: c-sharpcorner.com
Answer:
The CLR stands for Common Language Runtime and it is an Execution Environment. It works as a layer between Operating Systems and the applications written in .NET languages that conforms to the Common Language Specification (CLS). The main function of Common Language Runtime (CLR) is to convert the Managed Code into native code and then execute the program.
π Source: c-sharpcorner.com
Answer:
The Common Type System (CTS) standardizes the data types of all programming languages using .NET under the umbrella of .NET to a common data type for easy and smooth communication among these .NET languages.
CTS is designed as a singly rooted object hierarchy with System.Object
as the base type from which all other types are derived. CTS supports two different kinds of types:
- Value Types: Contain the values that need to be stored directly on the stack or allocated inline in a structure. They can be built-in (standard primitive types), user-defined (defined in source code) or enumerations (sets of enumerated values that are represented by labels but stored as a numeric type).
- Reference Types: Store a reference to the valueβs memory address and are allocated on the heap. Reference types can be any of the pointer types, interface types or self-describing types (arrays and class types such as user-defined classes, boxed value types and delegates).
π Source: c-sharpcorner.com
Answer:
- .NET Standard solves the code sharing problem for .NET developers across all platforms by bringing all the APIs that you expect and love across the environments that you need: desktop applications, mobile apps & games, and cloud services:
- .NET Standard is a set of APIs that all .NET platforms have to implement. This unifies the .NET platforms and prevents future fragmentation.
- .NET Standard 2.0 will be implemented by .NET Framework, .NET Core, and Xamarin. For .NET Core, this will add many of the existing APIs that have been requested.
- .NET Standard 2.0 includes a compatibility shim for .NET Framework binaries, significantly increasing the set of libraries that you can reference from your .NET Standard libraries.
- .NET Standard will replace Portable Class Libraries (PCLs) as the tooling story for building multi-platform .NET libraries.
π Source: stackoverflow.com
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
Questions Details:
Consider:
try
{
WebId = new Guid(queryString["web"]);
}
catch (FormatException)
{
WebId = Guid.Empty;
}
catch (OverflowException)
{
WebId = Guid.Empty;
}
Is there a way to catch both exceptions and only call the WebId = Guid.Empty
call once?
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
Q37: What is the difference between Class Library (.NET Standard) and Class Library (.NET Core)? βββ
See π Answer
See π Answer
Q39: What is the difference between .NET Framework/Core and .NET Standard Class Library project types? ββββ
See π Answer
See π Answer
Questions Details:
Consider:
private async Task<bool> TestFunction()
{
var x = await DoesSomethingExists();
var y = await DoesSomethingElseExists();
return y;
}
Does the second await
statement get executed right away or after the first await
returns?
See π Answer
See π Answer
Q43: Why does .NET use a JIT compiler instead of just compiling the code once on the target machine? ββββ
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
See π Answer
Q51: Could you name the difference between .Net Core, Portable, Standard, Compact, UWP, and PCL? βββββ
See π Answer