0

Lets say I have a sealed class Bank, and it has to properties string Name and int Code.

I have a custom attribute, AlertAttribute and I want to add it to each property in Bank class. How can I do that without modify the code of the Bank class? (no inheritance or partial class is allowed)

Is there any language mechanism to do it (compile-time)? Is it possible to add it by reflection (run-time)?

Thanks a lot.

eLopez

EDIT: I just want to know if it's possible at design time (compile-time) to add attributes with the constrains I exposed. If there none, I would consider to add at run-time, so given link to the answer would be implemented. Thanks

Edgar L
  • 3
  • 4
  • This is not possible. Since adding attributes is never the end goal, this sounds very much like an X/Y problem. What is the end goal that you are trying to achieve? – Sergey Kalinichenko Jul 24 '16 at 17:04
  • Hi, it's possible to have a compiled class where the source is not available or cannot be modified, so the idea is to know what options can be appropiated. – Edgar L Jul 24 '16 at 21:41

0 Answers0