You use attributes to connect metadata, including compiler directives, to an element in your code. There are plenty of attributes built into C#, and we've already seen a number of them in this book. For example, this attribute lets you indicate that a method is a Web method, accessible from a Web service:
This attribute lets you indicate that a class can be serialized:
This attribute indicates that you want to import a DLL; in this case, kernel32.dll:
Note the syntax in this case. We're passing text to the DLLImport attribute, followed by the expression SetLastError=true.
We also saw that you can use attributes to specify metadata about specific elements, ...