gpt4 book ai didi

c# - .NET 2.0 中不包含 modopt 关键字吗?

转载 作者:行者123 更新时间:2023-12-03 21:56:30 27 4
gpt4 key购买 nike

哪个版本的.NET框架包含关键字modopt

最佳答案

modopt 仅在 IL 中使用。 .NET 语言编译器的工作就是解释和生成它。 Ecma-335,分区 II,第 7.1.1 章提到了它:

Custom modifiers, defined using modreq (“required modifier”) and modopt (“optional modifier”), are similar to custom attributes (§21) except that modifiers are part of a signature rather than being attached to a declaration.

[Rationale: The distinction between required and optional modifiers is important to tools other than the CLI that deal with the metadata, typically compilers and program analysers. A required modifier indicates that there is a special semantics to the modified item that should not be ignored, while an optional modifier can simply be ignored.

For example, the const qualifier in the C programming language can be modelled with an optional modifier since the caller of a method that has a const-qualified parameter need not treat it in any special way. On the other hand, a parameter that shall be copy-constructed in C++ shall be marked with a required custom attribute since it is the caller who makes the copy. end rationale]

换句话说,它允许将元数据添加到对 CLR 不重要但对语言重要的声明中。 C++/CLI 编译器特别使用它。因此,.NET 必然没有与 const 关键字等价的关键字。

关于c# - .NET 2.0 中不包含 modopt 关键字吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5294254/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com