What does it mean to Decorate or add an attribute to a class or parameter?
What's the purpose and when would I do this?
Links to resources and direct answers are welcome.
When You add decorator in C# it is like adding a property to the class/method. There will be an attribute attached to it.
If You write Unit test You will meet a simple decorator TestMethod
like that:
[TestMethod]
public void TestMethod1()
{
}
The framework will use the decorators to check what test methods are in the test set.
You can check on the attribute here
There is another nice to read article about Writing Custom Attributes
Decorators are not limited to the '[ ]' form of decorators. There is also a design pattern for that, that was already mentioned before by others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With