Attributes

Attributes enable you to provide extra metadata to your classes and methods at compile time. Other programs can access this extra information either at compile time, runtime, or by simply reading the metadata.

The .NET Framework allows C# and other .NET languages to use some built-in attributes. These built-in attributes, derived from System.Attribute, are used for everything from conditional compilation to transactional support to specifying Web Services methods.

Using Attributes

To create a Web Services method, use the WebMethod attribute. Listing A.22 shows an example of this attribute.

Listing A.22. The WebMethod Attribute
[WebMethod]
public String MyMessage(){
   return "This is a Web Service method.";
}

When you specify the ...

Get Building e-Commerce Sites with the .NET Framework 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.