Information Technology Reference
In-Depth Information
Explicit target
[method: MyAttribute("Prints out a message.", "Version 3.6")]
[return: MyAttribute("This value represents ...", "Version 2.3")]
public long ReturnSetting()
{
...
The C# language defines 10 standardized attribute targets, which are listed in Table 21-1.
Most of the target names are self-explanatory, but type covers classes, structs, delegates,
enums, and interfaces. The typevar target name specifies type parameters to constructs that
use generics.
Table 21-1. Attribute Targets
event
field
method
param
property
return
type
typevar
assembly
module
Global Attributes
You can also use an explicit target to set attributes at the assembly and module level, by using
the assembly and module target names. Some important points about assembly-level attributes
are the following:
￿
Assembly-level attributes must be placed outside any namespace scope and are usually
placed in the AssemblyInfo.cs file.
￿The AssembyInfo.cs file usually contains metadata about the company, product, and
copyright information.
The following are lines from an AssemblyInfo.cs file.
[assembly: AssemblyTitle("SuperWidget")]
[assembly: AssemblyDescription("Implements the SuperWidget product.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("McArthur Widgets, Inc.")]
[assembly: AssemblyProduct("Super Widget Deluxe")]
[assembly: AssemblyCopyright("Copyright © McArthur Widgets 2006")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Search WWH ::




Custom Search