27.2. Standard attributes

Most of the time you will be using a standard attribute provided by the .NET framework. Standard attributes are 'picked up' and interpreted by the C# compiler to have special meanings. Unlike custom attributes, you do not need to write a special attribute class to use them. They have either been coded – and are part of the .NET BCLs – or are implicitly understood by the C# compiler.

I will examine two of the three standard attributes reserved by C# first – Obsolete and Conditional. The third reserved attribute, AttributeUsage, is a bit special and is discussed in Chapter 28.

27.2.1. The Obsolete attribute

This attribute is used to mark types and type members that should no longer be used. [7] You can use this attribute ...

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.