Chapter 27. C# attributes

C# attributes [1],[2] are a new feature with no equivalent in Java. [3] Put simply, C# attributes are comment-like tags enclosed in square brackets used to label or mark a class, interface, assembly, method, event, field, delegate, or method parameter in codes. Attributes enable these entities in source codes to be tagged with additional declarative information. These tags can be 'read' during runtime using C#'s built-in support for reflection.

[1] Do not be confused over the use of the term 'attribute'. In OO terminology (and also commonly in Java) the terms 'attribute', 'field', and 'property' are often used interchangeably to mean a class's field. In C#, 'fields' and 'properties' refer to different class members, ...

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.