.NET 中的 CIL、CLS 和 CTS

发布于 2024-08-16 21:09:50 字数 338 浏览 2 评论 0原文

什么是CILCTSCLS > 在.NET中它们之间有什么区别?

What is the CIL, CTS, and CLS in .NET and what is the difference between them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

友谊不毕业 2024-08-23 21:09:50

CIL(通用中间语言)是 C# 或 Visual Basic 代码编译后的字节代码。它是 .NET 执行引擎的“机器代码”。

CTS(通用类型系统)是编译级别的类型(类和结构)表示。基本上,它是说所有 .NET 语言都将使用表示类型(类和结构)的通用方式。

CLS(通用语言规范)是一组对 API 的约束,也是一组对语言的补充要求。如果一个库符合 CLS(即遵守所有约束),那么任何符合 CLS 的语言都可以使用该 API。相反,符合 CLS 的语言保证能够使用任何符合 CLS 的库。例如,符合 CLS 的语言保证支持 Int32,因此 CLS 保证库编写者在其 API 中使用 Int32 是安全的。

CIL (Common Intermediate Language) is the byte code to which your C# or Visual Basic code is compiled. It's the "machine code" of the .NET execution engine.

The CTS (Common Type System) is the representation of types (classes and structures) at the compiled level. Basically, it's saying that all .NET languages will use a common way of representing types (classes and structures).

The CLS (Common Language Specification) is a set of constraints on APIs and a complementary set of requirements on languages. If a library is CLS-compliant (i.e. adheres to all the constraints), then any CLS-compliant language will be able to use that API. Conversely, a CLS-compliant language is guaranteed to be able to use any CLS-compliant library. For example, a CLS-compliant language is guaranteed to support Int32, so the CLS guarantees it's safe for library writers to use Int32 in their APIs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文