βββ README.md
/README.md:
--------------------------------------------------------------------------------
1 | # .NET Core Interview Questions And Answers
2 |
3 | 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.
4 |
5 | > You could also find all the answers here π https://www.fullstack.cafe/.NET%20Core.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | ## Q1: What is .NET Core? β
14 |
15 | **Answer:**
16 |
17 | The .NET Core platform is a new .NET stack that is optimized for open source development and agile delivery on NuGet.
18 |
19 | .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.
20 |
21 | .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.
22 |
23 | π **Source:** [stackoverflow.com](https://stackoverflow.com/questions/26908049/what-is-net-core)
24 |
25 |
26 | ## Q2: What is the difference between String and string in C#? β
27 |
28 | **Answer:**
29 |
30 | `string` is an alias in C# for `System.String`. So technically, there is no difference. It's like `int` vs. `System.Int32`.
31 |
32 | As far as guidelines, it's generally recommended to use `string` any time you're referring to an object.
33 | ```csharp
34 | string place = "world";
35 | ```
36 |
37 | Likewise, it's generally recommended to use `String` if you need to refer specifically to the class.
38 | ```csharp
39 | string greet = String.Format("Hello {0}!", place);
40 | ```
41 |
42 | π **Source:** [blogs.msdn.microsoft.com](https://stackoverflow.com/questions/618535/difference-between-decimal-float-and-double-in-net)
43 |
44 |
45 | ## Q3: What is the .NET Framework? β
46 |
47 | **Answer:**
48 |
49 | 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:
50 |
51 | * Console Applications
52 | * Windows Forms Applications
53 | * Windows Presentation Foundation (WPF) Applications
54 | * Web Applications
55 | * Web Services
56 | * Windows Services
57 | * Services-oriented applications using Windows Communications Foundation (WCF)
58 | * Workflow-enabled applications using Windows Workflow Foundation(WF)
59 |
60 | π **Source:** [c-sharpcorner.com](https://www.c-sharpcorner.com/UploadFile/8ef97c/interview-question-on-net-framework-or-clr/)
61 |
62 |
63 | ## Q4: What is .NET Standard? β
64 |
65 | **Answer:**
66 |
67 | The **.NET Standard** is a formal specification of .NET APIs that are intended to be available on all .NET implementations.
68 |
69 | π **Source:** [docs.microsoft.com](https://docs.microsoft.com/en-us/dotnet/standard/net-standard)
70 |
71 |
72 | ## Q5: What is the difference between .NET Core and Mono? ββ
73 |
74 | **Answer:**
75 |
76 | To be simple:
77 | * Mono is third party implementation of .Net Framework for Linux/Android/iOs
78 | * .Net Core is Microsoft's own implementation for same.
79 |
80 | π **Source:** [stackoverflow.com](https://stackoverflow.com/questions/37738106/net-core-vs-mono)
81 |
82 |
83 | ## Q6: What are some characteristics of .NET Core? ββ
84 |
85 | **Answer:**
86 |
87 | * **Flexible deployment**: Can be included in your app or installed side-by-side user- or machine-wide.
88 |
89 | * **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.
90 |
91 | * **Command-line tools**: All product scenarios can be exercised at the command-line.
92 |
93 | * **Compatible**: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.
94 |
95 | * **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.
96 |
97 | * **Supported by Microsoft**: .NET Core is supported by Microsoft, per .NET Core Support
98 |
99 | π **Source:** [stackoverflow.com](https://stackoverflow.com/questions/26908049/what-is-net-core)
100 |
101 |
102 | ## Q7: What's the difference between SDK and Runtime in .NET Core? ββ
103 |
104 | **Answer:**
105 |
106 | * The SDK is all of the stuff that is needed/makes developing a .NET Core application easier, such as the CLI and a compiler.
107 |
108 | * The runtime is the "virtual machine" that hosts/runs the application and abstracts all the interaction with the base operating system.
109 |
110 | π **Source:** [stackoverflow.com](https://stackoverflow.com/questions/47733014/whats-the-difference-between-sdk-and-runtime-in-net-core)
111 |
112 |
113 | ## Q8: What is the difference between decimal, float and double in .NET? ββ
114 |
115 | **Questions Details:**
116 |
117 | When would someone use one of these?
118 |
119 |
120 | **Answer:**
121 |
122 | Precision is the main difference.
123 |
124 | * Float - 7 digits (32 bit)
125 | * Double-15-16 digits (64 bit)
126 | * Decimal -28-29 significant digits (128 bit)
127 |
128 | As for what to use when:
129 |
130 | * 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.
131 |
132 | * 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.
133 |
134 | π **Source:** [blogs.msdn.microsoft.com](https://stackoverflow.com/questions/618535/difference-between-decimal-float-and-double-in-net)
135 |
136 |
137 | ## Q9: What is an unmanaged resource? ββ
138 |
139 | **Answer:**
140 |
141 | Use that rule of thumb:
142 | * If you found it in the Microsoft .NET Framework: _it's managed_.
143 | * If you went poking around MSDN yourself, _it's unmanaged_.
144 |
145 | 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.
146 |
147 | π **Source:** [stackoverflow.com](https://stackoverflow.com/questions/538060/proper-use-of-the-idisposable-interface)
148 |
149 |
150 | ## Q10: What is MSIL? ββ
151 |
152 | **Answer:**
153 |
154 | 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.
155 |
156 | π **Source:** [c-sharpcorner.com](https://www.c-sharpcorner.com/UploadFile/8ef97c/interview-question-on-net-framework-or-clr/)
157 |
158 |
159 | ## Q11: What is a .NET application domain? ββ
160 |
161 | **Answer:**
162 |
163 | 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.
164 |
165 | App domains are useful because:
166 |
167 | * They are less expensive than full processes
168 | * They are multithreaded
169 | * You can stop one without killing everything in the process
170 | * Segregation of resources/config/etc
171 | * Each app domain runs on its own security level
172 |
173 | π **Source:** [stackoverflow.com](https://stackoverflow.com/questions/1094478/what-is-a-net-application-domain)
174 |
175 |
176 | ## Q12: Name some CLR services? ββ
177 |
178 | **Answer:**
179 |
180 | **CLR services**
181 |
182 | * Assembly Resolver
183 | * Assembly Loader
184 | * Type Checker
185 | * COM marshalled
186 | * Debug Manager
187 | * Thread Support
188 | * IL to Native compiler
189 | * Exception Manager
190 | * Garbage Collector
191 |
192 | π **Source:** [c-sharpcorner.com](https://www.c-sharpcorner.com/UploadFile/8ef97c/interview-question-on-net-framework-or-clr/)
193 |
194 |
195 | ## Q13: What is CLR? ββ
196 |
197 | **Answer:**
198 |
199 | 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.
200 |
201 | π **Source:** [c-sharpcorner.com](https://www.c-sharpcorner.com/UploadFile/8ef97c/interview-question-on-net-framework-or-clr/)
202 |
203 |
204 | ## Q14: What is CTS? ββ
205 |
206 | **Answer:**
207 |
208 | 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.
209 |
210 | 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:
211 |
212 | 1. **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).
213 | 2. **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).
214 |
215 | π **Source:** [c-sharpcorner.com](https://www.c-sharpcorner.com/UploadFile/8ef97c/interview-question-on-net-framework-or-clr/)
216 |
217 |
218 | ## Q15: What is .NET Standard and why we need to consider it? ββ
219 |
220 | **Answer:**
221 |
222 | 1. **.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:
223 | 2. **.NET Standard** is a **set of APIs** that **all** .NET platforms **have to implement**. This **unifies the .NET platforms** and **prevents future fragmentation**.
224 | 3. **.NET Standard 2.0** will be implemented by **.NET Framework**, .**NET Core**,
225 | and **Xamarin**. For **.NET Core**, this will add many of the existing APIs
226 | that have been requested.
227 | 3. **.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.
228 | 4. **.NET Standard** **will replace Portable Class Libraries (PCLs)** as the
229 | tooling story for building multi-platform .NET libraries.
230 |
231 |
232 |

233 |
234 |
235 | π **Source:** [stackoverflow.com](https://stackoverflow.com/questions/42939454/what-is-the-difference-between-net-core-and-net-standard-class-library-project)
236 |
237 |
238 | ## Q16: What is Kestrel? βββ
239 |
240 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
241 |
242 |
243 | ## Q17: Talk about new .csproj file? βββ
244 |
245 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
246 |
247 |
248 | ## Q18: What about NuGet packages and packages.config? βββ
249 |
250 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
251 |
252 |
253 | ## Q19: What is difference between .NET Core and .NET Framework? βββ
254 |
255 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
256 |
257 |
258 | ## Q20: Explain what is included in .NET Core? βββ
259 |
260 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
261 |
262 |
263 | ## Q21: What is .NET Standard? βββ
264 |
265 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
266 |
267 |
268 | ## Q22: What's the difference between .NET Core, .NET Framework, and Xamarin? βββ
269 |
270 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
271 |
272 |
273 | ## Q23: Explain two types of deployment for .NET Core applications βββ
274 |
275 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
276 |
277 |
278 | ## Q24: What is CoreCLR? βββ
279 |
280 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
281 |
282 |
283 | ## Q25: Is there a way to catch multiple exceptions at once and without code duplication? βββ
284 |
285 | **Questions Details:**
286 |
287 | Consider:
288 | ```csharp
289 | try
290 | {
291 | WebId = new Guid(queryString["web"]);
292 | }
293 | catch (FormatException)
294 | {
295 | WebId = Guid.Empty;
296 | }
297 | catch (OverflowException)
298 | {
299 | WebId = Guid.Empty;
300 | }
301 | ```
302 | Is there a way to catch both exceptions and only call the `WebId = Guid.Empty` call once?
303 |
304 |
305 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
306 |
307 |
308 | ## Q26: Why to use of the IDisposable interface? βββ
309 |
310 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
311 |
312 |
313 | ## Q27: Explain the difference between Task and Thread in .NET βββ
314 |
315 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
316 |
317 |
318 | ## Q28: What is FCL? βββ
319 |
320 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
321 |
322 |
323 | ## Q29: What's is BCL? βββ
324 |
325 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
326 |
327 |
328 | ## Q30: What is implicit compilation? βββ
329 |
330 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
331 |
332 |
333 | ## Q31: What is JIT compiler? βββ
334 |
335 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
336 |
337 |
338 | ## Q32: What is Explicit Compilation? βββ
339 |
340 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
341 |
342 |
343 | ## Q33: What are the benefits of explicit compilation? βββ
344 |
345 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
346 |
347 |
348 | ## Q34: What does Common Language Specification (CLS) mean? βββ
349 |
350 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
351 |
352 |
353 | ## Q35: Explain the difference between βmanagedβ and βunmanagedβ code? βββ
354 |
355 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
356 |
357 |
358 | ## Q36: What is the difference between .NET Standard and PCL (Portable Class Libraries)? βββ
359 |
360 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
361 |
362 |
363 | ## Q37: What is the difference between Class Library (.NET Standard) and Class Library (.NET Core)? βββ
364 |
365 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
366 |
367 |
368 | ## Q38: When should we use .NET Core and .NET Standard Class Library project types? βββ
369 |
370 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
371 |
372 |
373 | ## Q39: What is the difference between .NET Framework/Core and .NET Standard Class Library project types? ββββ
374 |
375 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
376 |
377 |
378 | ## Q40: What's the difference between RyuJIT and Roslyn? ββββ
379 |
380 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
381 |
382 |
383 | ## Q41: Explain how does Asynchronous tasks (Async/Await) work in .NET? ββββ
384 |
385 | **Questions Details:**
386 |
387 | Consider:
388 | ```csharp
389 | private async Task TestFunction()
390 | {
391 | var x = await DoesSomethingExists();
392 | var y = await DoesSomethingElseExists();
393 | return y;
394 | }
395 | ```
396 | Does the second `await` statement get executed right away or after the first `await` returns?
397 |
398 |
399 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
400 |
401 |
402 | ## Q42: What are benefits of using JIT? ββββ
403 |
404 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
405 |
406 |
407 | ## Q43: Why does .NET use a JIT compiler instead of just compiling the code once on the target machine? ββββ
408 |
409 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
410 |
411 |
412 | ## Q44: What is the difference between CIL and MSIL (IL)? ββββ
413 |
414 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
415 |
416 |
417 | ## Q45: What is the difference between AppDomain, Assembly, Process, and a Thread? ββββ
418 |
419 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
420 |
421 |
422 | ## Q46: Why does .NET Standard library exist? ββββ
423 |
424 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
425 |
426 |
427 | ## Q47: How to choose the target version of .NET Standard library? ββββ
428 |
429 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
430 |
431 |
432 | ## Q48: Explain Finalize vs Dispose usage? βββββ
433 |
434 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
435 |
436 |
437 | ## Q49: What is the difference between Node.js async model and async/await in .NET? βββββ
438 |
439 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
440 |
441 |
442 | ## Q50: How many types of JIT Compilations do you know? βββββ
443 |
444 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
445 |
446 |
447 | ## Q51: Could you name the difference between .Net Core, Portable, Standard, Compact, UWP, and PCL? βββββ
448 |
449 | See π **[Answer](https://www.fullstack.cafe/.NET%20Core)**
450 |
451 |
452 |
--------------------------------------------------------------------------------