When are method attributes evaluated?

ⅰ亾dé卋堺 提交于 2019-12-11 06:09:43

问题


[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?


回答1:


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.



来源:https://stackoverflow.com/questions/21004932/when-are-method-attributes-evaluated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!