<include> (C# Programming Guide)


<include file='filename' path='tagpath[@name="id"]' />


The name of the XML file containing the documentation. The file name can be qualified with a path. Enclose filename in single quotation marks (' ').


The path of the tags in filename that leads to the tag name. Enclose the path in single quotation marks (' ').


The name specifier in the tag that precedes the comments; name will have an id.


The ID for the tag that precedes the comments. Enclose the ID in double quotation marks (" ").

The <include> tag lets you refer to comments in another file that describe the types and members in your source code. This is an alternative to placing documentation comments directly in your source code file. By putting the documentation in a separate file, you can apply source control to the documentation separately from the source code. One person can have the source code file checked out and someone else can have the documentation file checked out.

The <include> tag uses the XML XPath syntax. Refer to XPath documentation for ways to customize your <include> use.

This is a multifile example. The first file, which uses <include>, is listed below:

string s = Enum.GetName(typeof(Days), 4);

Console.WriteLine("The values of the Days Enum are:");
foreach (int i in Enum.GetValues(typeof(Days)))

Console.WriteLine("The names of the Days Enum are:");
foreach (string str in Enum.GetNames(typeof(Days)))

The second file, xml_include_tag.doc, contains the following documentation comments:


<MyMembers name="test">
The summary for this type.

<MyMembers name="test2">
The summary for this other type.


The following output is generated when you compile the Test and Test2 classes with the following command line: /doc:DocFileName.xml. In Visual Studio, you specify the XML doc comments option in the Build pane of the Project Designer. When the C# compiler sees the <inclue> tag, it will search for documentation comments in xml_include_tag.doc instead of the current source file. The compiler then generates DocFileName.xml, and this is the file that is consumed by documentation tools such as Sandcastle to produce the final documentation.

<?xml version="1.0"?> 
        <member name="T:Test"> 
The summary for this type. 
        <member name="T:Test2"> 
The summary for this other type. 
© 2015 Microsoft