Overview [ Documentation]

C# source files can contain structured comments (XML doc) that produce API documentation for the types contained therein. The compiler creates an XML files that contains structured data representing the comments and the API signatures. Other tools can process these XML files to produce human-readable documentation.

Generating XML Documentation

To enable XML documentation:


With this switch enabled, the compiler generates warning CS1591 for any publicly visible member without XML doc.

XML Comment Style Guide

  • All public types and their public members should be documented.
  • At minimum, types and their members should have a <summary> tag.
  • Private members can be documented, but consider that this exposes the inner workings of a type.
  • Documentation text should be written using complete sentences with full stops.
  • Partial classes are fully supported and the documentation is concatenated into a single entry for each type.

General Constructs

  • /// — Single-line delimiter. Any following whitespace is ignored.
  • /** */ — Multi-line delimiter. Used for comments. Comments are not included in the compiled assembly.
  • cref — A tag meaning “code reference.” Specifies that the text is a code element (a type, method, property, etc).
  • href — A reference to a web page. Used to link directly to a web page.

General Tags


  • Describes a type or a type member.
  • The text in this tag is the only source of information for IntelliSense.


  • Adds additional information about a type or a type member.
    additional information

Member Tags


  • Used in the comment for a method declaration to describe the return value.


  • Used in the comment for a method declaration to describe one of the parameters of that method.
  • Use multiple tags to document multiple parameters.
  • The name parameter must match the API signature.
<param name="name">description</param>


  • Used to indicate that a word in the comments (like in a <summary> tag) refers to a parameter.
  • "name" is the name of the actual method parameter.
<paramref name="name"/>


  • Used to specify which exceptions can be thrown.
<exception cref="member">description</exception>


  • Used to describe the value that a property represents.

Formatting Tags


  • Used inside other tags to create a double-spaced paragraph.
  • Use <br /> for a single-spaced paragraph.
        This is an introductory paragraph.
        This paragraph contains more details.


  • Used to define a bulleted list, numbered list, definition list, or table.
List typeRequires <listheader>?Required <listheader> membersRequired <item> members
Definition ListYesN/A<term>
Other listsNoN/A<description>
<list type="bullet|number|table">
        <description>The library or executable built from a compilation.</description>

<c> and <code>

  • Used to indicate that text within a description should be marked as code.
  • Use <c> for single lines and <code> for multiple lines.
    var index = 5;


  • Used to show how to use a method or other member.
This shows how to increment an integer.
    var index = 5;

Tags for Generic Types and Methods


  • Used in the comment for a generic type or method to describe a type parameter.
<typeparam name="TResult">The type returned from this method</typeparam>


  • Used to enable consumers of the resulting documentation file to format the word in a distinct way (perhaps italicized, for example).
<typeparamref name="TKey"/>

Reusing Documentation Text


  • Inherits XML comments from base classes, interfaces, and similar methods (such as MethodName and MethodNameAsync).
  • With no arguments, this inheritance is automatic.
  • cref — the member to inherit documentation from.
  • path — the XPath used to filter the tags to include or exclude from the inherited documentation.
<inheritdoc [cref=""] [path=""]/>


  • References comments in another file.
  • file — the name of the XML file containing the documentation with a path relative to the source code file.
    • Note that the file name is in single quotes.
<include file='filename' path='tagpath[@name="id"]' />


  • Used to specify a link from within the text.
  • cref — a reference to a member to create hyperlinks to documentation pages for code elements. For example:
    • cref="IDictionary{T, U}"
  • href — a clickable link to a URL.
  • langword — a language keyword such as true
<see cref="member"/>
<!-- or -->
<see cref="member">Link text</see>
<!-- or -->
<see href="link">Link Text</see>
<!-- or -->
<see langword="keyword"/>


  • Like <see> but specifies the text should appear in the See Also section.