<summary>(C# 编程指南)

<summary>description</summary>

参数

  • description
    对象的摘要。

备注

<summary> 标记应当用于描述类型或类型成员。 使用 <remarks> 添加针对某个类型说明的补充信息。 使用 cref 特性可启用文档工具(如 Sandcastle)来创建指向代码元素的文档页内部超链接。

<summary> 标记的文本是唯一有关 IntelliSense 中的类型的信息源,它也显示在 对象浏览器 中。

使用 /doc 进行编译可以将文档注释处理到文件中。 若要基于编译器生成的文件创建最终文档,可以创建一个自定义工具,也可以使用 Sandcastle 等工具。

示例

// compile with: /doc:DocFileName.xml 

/// text for class TestClass
public class TestClass
{
    /// <summary>DoWork is a method in the TestClass class.
    /// <para>Here's how you could make a second paragraph in a description. <see cref="System.Console.WriteLine(System.String)"/> for information about output statements.</para>
    /// <seealso cref="TestClass.Main"/>
    /// </summary>
    public static void DoWork(int Int1)
    {
    }

    /// text for Main
    static void Main()
    {
    }
}

下面的示例演示如何对泛型类型进行 cref 引用。

// compile with: /doc:DocFileName.xml 

// the following cref shows how to specify the reference, such that,
// the compiler will resolve the reference
/// <summary cref="C{T}">
/// </summary>
class A { }

// the following cref shows another way to specify the reference, 
// such that, the compiler will resolve the reference
// <summary cref="C &lt; T &gt;">

// the following cref shows how to hard-code the reference
/// <summary cref="T:C`1">
/// </summary>
class B { }

/// <summary cref="A">
/// </summary>
/// <typeparam name="T"></typeparam>
class C<T> { }

请参见

参考

建议的文档注释标记(C# 编程指南)

概念

C# 编程指南