/// This method changes the point's location by /// the given x- and y-offsets. /// For example: ///Point p = new Point(3,5); /// p.Translate(-1,3); /// results in p's having the value (2,8). publicvoidTranslate(int xor, int yor) { X += xor; Y += yor; }
/// This is the entry point of the Point class testing program. /// This program tests each method and operator, and /// is intended to be run after any non-trvial maintenance has /// been performed on the Point class. publicstaticvoidMain() { // ... }
A.2.8
该标记用于描述方法、构造函数或索引器的参数。
语法:description 其中name参数名。description参数的描述。
示例:
/// This method changes the point's location to /// the given coordinates. ///the new x-coordinate. ///the new y-coordinate. publicvoidMove(int xor, int yor) { X = xor; Y = yor; }
A.2.9
该标记表示某单词是一个参数。这样,生成文档文件后经适当处理,可以用某种独特的方法来格式化该参数。
语法:
name
其中
name
参数名。
示例:
/// This constructor initializes the new Point to /// (,). ///the new Point's x-coordinate. ///the new Point's y-coordinate.
publicPoint(int xor, int yor) { X = xor; Y = yor; }
A.2.10
该标记用于将成员的安全性和可访问性记入文档。
语法:
description
其中
cref="member"
成员的名称。文档生成器检查给定的代码元素是否存在,并将 member 转换为文档文件中的规范化元素名称。
description
对成员的访问属性的说明。
示例:
/// Everyone can /// access this method.
publicstaticvoidTest() { // ... }
A.2.11
该标记用于指定类型的概述信息。(使用 (第 A.2.15 节)描述类型的成员。)
语法
description
其中
description
摘要文本。
示例:
/// Class Point models a point in a /// two-dimensional plane. publicclassPoint { // ... }
A.2.12
该标记用于描述方法的返回值。
语法:
description
其中
description
返回值的说明。
示例:
/// Report a point's location as a string. /// A string representing a point's location, in the form (x,y), /// without any leading, trailing, or embedded whitespace. publicoverridestringToString() { return"(" + X + "," + Y + ")"; }
A.2.13
该标记用于在文本内指定链接。使用 (第 A.2.14 节)指示将在“请参见”部分中出现的 文本。
语法:
member"/
其中
cref="member"
成员的名称。文档生成器检查给定的代码元素是否存在,并将 member 更改为所生成的文档文件中的元素名称。
示例:
/// This method changes the point's location to /// the given coordinates. /// publicvoidMove(int xor, int yor) { X = xor; Y = yor; }
/// This method changes the point's location by /// the given x- and y-offsets. /// /// publicvoidTranslate(int xor, int yor) { X += xor; Y += yor; }
A.2.14
该标记用于生成将列入“请参见”部分的项。使用 (第 A.2.13 节)指定来自文本内的链接。
语法:
member"/
其中
cref="member"
成员的名称。文档生成器检查给定的代码元素是否存在,并将 member 更改为所生成的文档文件中的元素名称。
示例:
/// This method determines whether two Points have the same /// location. /// /// publicoverrideboolEquals(object o) { // ... }
A.2.15
可以用此标记描述类型的成员。使用 (第 A.2.11 节)描述类型本身。
语法:
description
其中
description
关于成员的摘要描述。
示例:
/// This constructor initializes the new Point to (0,0). publicPoint() : this(0,0) { }
A.2.16
该标记用于描述属性。
语法:
propertydescription
其中
property description
属性的说明。
示例:
/// Property X represents the point's x-coordinate. publicint X { get { return x; } set { x = value; } }
A.3.处理文档文件
文档生成器为源代码中每个附加了“文档注释标记”的代码元素生成一个 ID 字符串。该 ID 字符串唯一地标识源元素。文档查看器利用此 ID 字符串来标识该文档所描述的对应的元数据/反射项。
namespaceAcme { classWidget: IProcess { publicint Width { get {...} set {...} } publicintthis[int i] { get {...} set {...} } publicintthis[string s, int i] { get {...} set {...} } } }