Jon Jagger
jon@jaggersoft.com
Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specificationpreviousnextprevious at this levelnext at this level 24 Attributesprevious at this levelnext at this level 24.1 Attribute classesprevious at this levelnext at this level 24.1.2 Positional and named parameters Paragraph 11 Attribute classes can have positional parameters and named parameters. 2 Each public instance constructor for an attribute class defines a valid sequence of positional parameters for that attribute class. 3 Each non-static public read-write field and property for an attribute class defines a named parameter for the attribute class. [Example: The example
using System;  
[AttributeUsage(AttributeTargets.Class)]  
public class HelpAttribute: Attribute  
{  
   public HelpAttribute(string url) {  // url is a positional parameter  
      ...  
   }  
   public string Topic {  // Topic is a named parameter  
      get {...}  
      set {...}  
   }  
   public string Url { get {...} }  
}  
defines an attribute class named HelpAttribute that has one positional parameter (string url) and one named parameter (string Topic). Although it is non-static and public, the property Url does not define a named parameter, since it is not read-write.
This attribute class might be used as follows:
[Help("http://www.mycompany.com/.../Class1.htm")]  
class Class1 {  
}  
[Help("http://www.mycompany.com/.../Misc.htm", Topic ="Class2")]  
class Class2 {  
}  
end example]
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS