NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

17.1.2 Positional and named parameters

Attribute classes can have positional parameters and named parameters. Each public constructor for an attribute class defines a valid sequence of positional parameters for the attribute class. Each non-static public read-write field and property for an attribute class defines a named parameter for the attribute class.

The example

[AttributeUsage(AttributeTargets.Class]
public class HelpAttribute: System.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 argument (string Topic). The read-only Url property does not define a named parameter. It is non-static and public, but since it is read-only it does not define a named parameter.

The example

[HelpAttribute("http://www.mycompany.com/…/Class1.htm")]
class Class1 {
}
[HelpAttribute("http://www.mycompany.com/…/Misc.htm", Topic ="Class2")]
class Class2 {
}

shows several uses of the attribute.