方法属性时进行评估? [英] When are method attributes evaluated?

查看:154
本文介绍了方法属性时进行评估?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  [CustomMethodAttribute]
公共无效的MyMethod(字串[] args)
{
    //执行一些
}

在将 CustomMethodAttribute 进行评估,你可以做任何事情的时候这样评价发生改变?此外,关心解释编译究竟是如何管理这一招?


解决方案

  

在将CustomMethodAttribute进行评估,你可以做任何事情的时候这样评价发生改变?


在一般情况下,也没有评估,发生。自定义属性被添加到方法的元数据的,并且可进行通过反射在运行时根据需要进行检查。

有关详细信息,请参阅属性MSDN上

[CustomMethodAttribute]
public void MyMethod(string[] args)
{
    // Some implementation
}

When will CustomMethodAttribute be evaluated and can you do anything to change when this evaluation takes place? Also, care to explain exactly how the compiler manages this trick?

解决方案

When will CustomMethodAttribute be evaluated and can you do anything to change when this evaluation takes place?

In general, there is no evaluation that takes place. A custom attribute is added to the method as metadata, and available to be inspected via reflection at runtime as needed.

For details, see Attributes on MSDN.

这篇关于方法属性时进行评估?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆