Reputation: 1422
[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?
Upvotes: 1
Views: 527
Reputation: 564403
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.
Upvotes: 3