Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/csharp/tour-of-csharp/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ All attribute classes derive from the <xref:System.Attribute> base class provide

This example attaches a `HelpAttribute` to the `Widget` class. It adds another `HelpAttribute` to the `Display` method in the class. The public constructors of an attribute class control the information that must be provided when the attribute is attached to a program entity. Additional information can be provided by referencing public read-write properties of the attribute class (such as the reference to the `Topic` property previously).

When a particular attribute is requested through reflection, the constructor for the attribute class is invoked with the information provided in the program source, and the resulting attribute instance is returned. If additional information was provided through properties, those properties are set to the given values before the attribute instance is returned.
The metadata defined by attributes can be read and manipulated at runtime using reflection. When a particular attribute is requested using this technique, the constructor for the attribute class is invoked with the information provided in the program source, and the resulting attribute instance is returned. If additional information was provided through properties, those properties are set to the given values before the attribute instance is returned.

The following code sample demonstrates how to get the `HelpAttribute` instances associated to the `Widget` class and its `Display` method.

[!code-csharp[AttributeRead](../../../samples/snippets/csharp/tour/attributes/Program.cs#L34-L54)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than the line numbers, let's use a snippet reference:

[!code-csharpAttributeRead]

(If you name the snippet as I did in the samples PR)


>[!div class="step-by-step"]
[Previous](delegates.md)