I have an existing C# class that I cannot modify, but only use it. By example:
public class Test {}
I would like to add dynamically an attribute (MyAttribute) to this class Test, like:
[MyAttribute(TestMode)]
public class Test {}
Is it possible in C# and how?
Note: of course, I can derive from this Test class and add declaratively the attribute, but it means to create a new class, and I'd like to avoid it.
Classand therefore it's absolutely not related with dynamically add information to anObject. What do you want do do? I'm sure the solution is something else.