elucid8
elucid8

Reputation: 1422

When are method attributes evaluated?

[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

Answers (1)

Reed Copsey
Reed Copsey

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

Related Questions