共用方式為


<include> (C# 程式設計手冊)

更新:2007 年 11 月

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

參數

  • filename
    為含有文件的檔案名稱。可將檔案名稱加上路徑。以單引號 (' ') 將 filename 括起來。

  • tagpath
    filename 中的標記路徑,會指向標記 name。以單引號 (' ') 將路徑括起來。

  • name
    註解前面標記內的名稱規範。name 會有一個 id。

  • id
    註解前面之標記的 ID。以雙引號 (" ") 將 ID 括住。

備註

<include> 標記讓您參考其他檔案內的註解,這些檔案描述了您原始程式碼中的型別以及成員。除了將文件註解直接放置在您原始程式碼檔案中,您也可以使用這種方法。

<include> 標記使用了 XML XPath 的語法。請參閱 XPath 文件,以取得自訂 <include> 用途的方法。

範例

這是多重檔案的範例。第一個檔案使用 <include>,列於下方:

// compile with: /doc:DocFileName.xml 

/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test"]/*' />
class Test
{
    static void Main()
    {
    }
}

/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test2"]/*' />
class Test2
{
    public void Test()
    {
    }
}

第二個檔案 (xml_include_tag.doc) 包含下列的文件註解。

<MyDocs>

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

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

</MyDocs>

程式輸出

<?xml version="1.0"?>

<doc>

<assembly>

<name>xml_include_tag</name>

</assembly>

<members>

<member name="T:Test">

<summary>

The summary for this type.

</summary>

</member>

<member name="T:Test2">

<summary>

The summary for this other type.

</summary>

</member>

</members>

</doc>

請參閱

概念

C# 程式設計手冊

參考

建議使用的文件註解標籤 (C# 程式設計手冊)