ConditionalAttribute等特殊类

编程入门 行业动态 更新时间:2024-10-24 06:26:55
本文介绍了ConditionalAttribute等特殊类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

ConditionalAttribute 可用于消除呼叫取决于所定义的编译器的符号的显着的方法。我假设我们不能创建该类自己,因为编译器必须专门寻找它。

The ConditionalAttribute can be used to remove calls to a marked method depending on the compiler symbols defined. I'm assuming we could not create this class ourselves since the compiler must be looking for it specifically.

我想知道其他班级也有编译器,或者使用的语言,我们不能code自己。

I was wondering what other classes there are that the compiler, or language uses that we could not code ourselves.

推荐答案
  • 编译器查找 [ExtensionAttribute] 指示扩展方法(和包含扩展方法的类)。

  • The compiler looks for [ExtensionAttribute] to indicate extension methods (and classes containing extension methods).

    [ DynamicAttribute] 是用来表示一个成员都应该为类型进行治疗动态(即使会员类型本身也只是对象)

    [DynamicAttribute] is used to indicate that a member should be treated as type dynamic (even though the member type itself will just be object)

    [InternalsVisibleTo] 允许一个程序集访问另一个人的内部成员。

    [InternalsVisibleTo] allows one assembly to access the internal members of another.

    基本上去翻 System.Runtime.CompilerServices 命名空间,并检查存在的属性......许多人将予以特殊的在的编译器,即使它不是C#编译器(例如: DateTimeConstantAttribute 是不使用C#编译器,据我所知,但 DecimalConstantAttribute 是,它是的可能的是,C#编译器的消耗的恒的DateTime 即使它不会产生这些价值观......)

    Basically look through the System.Runtime.CompilerServices namespace, and examine the attributes in there... many of them will be handled specially by a compiler, even if it's not the C# compiler (e.g. DateTimeConstantAttribute isn't used by the C# compiler as far as I'm aware, but DecimalConstantAttribute is. It's possible that the C# compiler will consume constant DateTime values even though it won't produce them...)

更多推荐

ConditionalAttribute等特殊类

本文发布于:2023-11-06 01:26:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562376.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ConditionalAttribute

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!