清单 9.5 利用 <summary>, <see>, <para>, and <seealso> 标签描述一个成员
1: using System;
2: using System.Net;
3: using System.IO;
4: using System.Text;
5:
6: /// <summary>Class to tear a Webpage from a Webserver</summary>
7: public class RequestWebPage
8: {
9: private const int BUFFER_SIZE = 128;
10:
11: /// <summary>m_strURL stores the URL of the Webpage</summary>
12: private string m_strURL;
13:
14: /// <summary>RequestWebPage() is the constructor for the class
15: /// <see cref="RequestWebPage"/> when called without arguments.</summary>
16: public RequestWebPage()
17: {
18: }
19:
20: /// <summary>RequestWebPage(string strURL) is the constructor for the class
21: /// <see cref="RequestWebPage"/> when called with an URL as parameter.</summary>
22: public RequestWebPage(string strURL)
23: {
24: m_strURL = strURL;
25: }
26:
27: public string URL
28: {
29: get { return m_strURL; }
30: set { m_strURL = value; }
31: }
32:
33: /// <summary>The GetContent(out string strContent) method:
34: /// <para>Included in the <see cref="RequestWebPage"/> class</para>
35: /// <para>Uses variable <see cref="m_strURL"/></para>
36: /// <para>Used to retrieve the content of a Webpage. The URL
37: /// of the Webpage (including http://) must already be
38: /// stored in the private variable m_strURL.
39: /// To do so, call the constructor of the RequestWebPage
40: /// class, or set its property <see cref="URL"/> to the URL string.</para>
41: /// </summary>
42: /// <seealso cref="System.Net"/>
43: /// <seealso cref="System.Net.WebResponse"/>
44: /// <seealso cref="System.Net.WebRequest"/>
45: /// <seealso cref="System.Net.WebRequestFactory"/>
46: /// <seealso cref="System.IO.Stream"/>
47: /// <seealso cref="System.Text.StringBuilder"/>
48: /// <seealso cref="System.ArgumentException"/>
49:
50: public bool GetContent(out string strContent)
51: {
52: strContent = "";
53: // ……
54: return true;
55: }
56: }
9.2.2 添加备注和列表
<remarks> 标签是规定大量文档的地方。与之相比, <summary>只仅仅规定了成员的简短描述。
你不限于只提供段落文本(使用<para>标签)。例如,你可以在备注部分包含bulleted(和有限偶数)列表
(list):
/// <list type="bullet">
/// <item>Constructor
/// <see cref="RequestWebPage()"/> or
/// <see cref="RequestWebPage(string)"/>
/// </item>
/// </list>
这个list有一项(item),且该item引用了两个不同的构造函数描述。你可以根据需要,任意往list item中添加内容。
另一个在备注部分很好用的标签是<paramref>.例如,你可以用<paramref>来引用和描述传递给构造函数的参数:
/// <remarks>Stores the URL from the parameter /// <paramref name="strURL"/> in
/// the private variable <see cref="m_strURL"/>.</remarks>
public RequestWebPage(string strURL)
在清单9.6中,你可以看到所有的这些以及前面的标签正在起作用。

