2008-12-04 65 views
10

爲了引用類的成員XML註釋/文檔,您必須使用以下標籤:如何引用C#類的索引成員評論

<see cref="member"/> 

這是更好地解釋here

你如何參考索引器

我的意思是,像這樣的一個成員:

internal object this[ int index ] { 
    ... 
} 

在此先感謝。

回答

11
<see cref="P:System.Collections.ArrayList.Item(System.Int32)" /> 
+0

能否詳細說明一下? P在所有這些東西面前的含義是什麼?屬性? – Auron 2008-12-04 16:13:28

4
<see cref="this[int]" /> 
1

在一般情況下,爲了一探究竟,如何引用任何成員在您的意見,發現在裝配您的XML文檔文件的成員。它在每個版本上創建。隨着仿製藥的唯一例外的成員引用從這裏可以採取:

</member> 
<member name="P:My.Namespace.Class1.Item(System.String)"> 
    <summary> 
     retrieve a single item of the given name from this instance 
    </summary> 
    <param name="name">name of the item</param> 
    <returns>the item</returns> 
</member> 
<member name="M:My.Namespace.Class1.Function1(System.Int32[])"> 
    <summary> 
    ... 

不幸的是,一般的高清格式似乎不是文檔文件和CREF標籤之間的兼容。雖然在XML文件中,仿製藥看起來像:

<member name="M:My.Namespace.Class1.Get``1(System.String)"> 
    <summary> 
    retrieve an named item of the given type 
    </summary> 
    <typeparam name="T">the type of the item to retrieve</typeparam> 
    ... 

cref標籤期望他們在下列格式之一:

/// <seealso cref="M:My.Namespace.Class1.Get{T}(System.String)"/> 

/// <seealso cref="M:My.Namespace.Class1.Get&lt;T>(System.String)"/> 
1

我有同樣的問題,但有通用 Dictionary.Item(TKey)屬性。該answer by leppie

<see cref="P:System.Collections.ArrayList.Item(System.Int32)" />

additional link by ICR(可惜我找不到 「mscorlib.xml」)

MSDN: Processing the XML File (C# Programming Guide)

幫了我。

the answer by user492238
(我知道,我應該直接評論他的回答。但由於我是新,這是我的第一篇文章,請寬容我,因爲我不允許因爲我的低信譽發表意見。 )

<seealso cref="M:My.Namespace.Class1.Get{T}(System.String)"/>
<seealso cref="M:My.Namespace.Class1.Get&lt;T>(System.String)"/>

僅在平原,黑色文本,由此僅使秒針顯示標籤標牌<>給出 「硬編碼」 造成的。

我發現MSDN頁面上的解決方案中使用反引號(')的仿製藥和我的xmlDoc中,內有一個完整的(「colory」)對類和屬性引用:

<see cref="P:System.Collections.Generic.Dictionary`2.Item(`0)" /> 
Dictionary<TKey, TValue>.this[TKey] 
1
<see cref="ReadOnlyCollection{T}.this[int]" /> 

如提議的here