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

What does Common Language Specification (CLS) mean?

Câu trả lời

The Common Language Specification (CLS) is a set of rules and guidelines defined by the .NET Framework to ensure interoperability among different .NET programming languages. It is a subset of the Common Type System (CTS) and specifies the features that all .NET languages must support to be considered CLS-compliant. This allows code written in one CLS-compliant language to be used by another CLS-compliant language seamlessly.

Key Points about CLS:

  1. Interoperability: CLS ensures that different .NET languages can interoperate by adhering to a common set of rules and restrictions. This means that components written in one language can be used in another language without compatibility issues[1][3][5].
  2. Subset of CTS: CLS is a subset of the Common Type System (CTS), which defines how types are declared, used, and managed in the runtime. While CTS covers a broader range of types and operations, CLS focuses on the common subset that is shared across all .NET languages[3][5][9].
  3. Language Independence: By following CLS, developers can write code that is language-independent, meaning it can be compiled and executed across different .NET languages like C#, VB.NET, F#, etc.[1][4][6].
  4. Rules and Restrictions: CLS defines specific rules such as not allowing multiple inheritance, ensuring case-insensitivity in member names, and other constraints to maintain compatibility across languages[1][5][9].
  5. CLS Compliance: To make an assembly CLS-compliant, developers can use the CLSCompliant attribute in their code. This attribute indicates that the assembly adheres to the CLS rules, making it accessible to other CLS-compliant languages[10][13].

Example:

A common rule in CLS is that method names should not differ only by case. For instance, having methods Add() and add() in the same class would violate CLS because some languages, like VB.NET, are not case-sensitive[1][5].

Conclusion:

The Common Language ...

middle

middle

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

junior

What is an unmanaged resource in .NET?

middle

What is CoreCLR?

junior

What is a .NET application domain?

Bình luận

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

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