Câu hỏi phỏng vấn .NET Core
Câu hỏi

What is MSIL?

Câu trả lời

Microsoft Intermediate Language (MSIL), also known as Intermediate Language (IL) or Common Intermediate Language (CIL), is a CPU-independent set of instructions that can be efficiently converted to native code. It is a key component of the .NET framework, enabling platform independence and language interoperability.

Key Points about MSIL:

  1. Compilation Process:

    • When you write code in a .NET language such as C# or VB.NET, the source code is compiled into MSIL by a language-specific compiler[1][4][10].
    • This intermediate code is stored in a portable executable (PE) file along with metadata that describes the types, members, and references in the code[1][4].
  2. Execution Process:

    • At runtime, the Common Language Runtime (CLR) uses a Just-In-Time (JIT) compiler to convert the MSIL into native machine code specific to the operating system and hardware[1][4][8].
    • This process ensures that the code can run on any platform that supports the .NET runtime, providing platform independence[3][4].
  3. Features of MSIL:

    • MSIL is object-oriented and includes instructions for loading, storing, initializing, and calling methods on objects, as well as for arithmetic and logical operations, control flow, direct memory access, and exception handling[1][3][4].
    • It supports standard object-oriented features such as abstraction, inheritance, polymorphism, and encapsulation[2][3].
  4. Benefits:

    • Platform Independence: MSIL allows the same code to be executed on different platforms without modification, as the final compilation to native code happens at runtime[3][4].
    • Language Interoperability: Different programming languages can be used within the same application, as they all compile down to MSIL, which can then be executed by the CLR[4][10].
    • Security and Reliability: MSIL code is verified for type safety and other security checks during runtime, reducing the risk of certain types of vulnerabilities[3][4].
  5. Standardization:

    • MSIL was originally known as Microsoft Intermediate Language but was renamed to Common Intermediate Language (CIL) as part of the standardization of the .NET framework and C# by ECMA[3][12][14].

Example of MSIL Code:

Here is a simple example of C# code and its corresponding MSIL:

C# Code:

using System;
public class Demo {...
junior

junior

Gợi ý câu hỏi phỏng vấn

senior

How to choose the target version of .NET Standard library?

senior

Does .NET support Multiple Inheritance?

senior

What is the difference between .NET Framework/Core and .NET Standard Class Library project types?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào