2010-03-02 34 views
6

我正在嘗試編寫文檔註釋,但是我遇到了問題。如何將< >包含的項目添加到文檔註釋

/// <summary> 
/// Inserts an element into the System.Collections.Generic.List<T> at the specified 
/// index. 
/// </summary> 

當我到達<T>視覺工作室認爲我想添加另一個標籤。什麼是正確的方式來添加這樣的評論(如果我可以讓他們點擊生成的幫助文本,這將是一個額外的獎勵)

回答

10

C#文檔註釋XML,那麼改變你<>&lt;&gt;

你最好做的是使用<see>標籤插入超鏈接。在<see>標籤,更改<T>{T}

/// <summary> 
/// Inserts an element into the <see cref="List{T}"/> at the specified 
/// index. 
/// </summary> 

(注意cref屬性是語法檢查的編譯器,不像普通的文本。)

0

由於評論是XML,你可以使用適當的轉義序列爲XML:

/// Inserts an element into the System.Collections.Generic.List&lt;T&gt; at the specified 
2

轉義xml實體。

 
Change <T> into &lt;T&gt; 
2

我相信這將是對你的幫助: C# XML documentation comments FAQ

+0

謝謝你,我永遠愛一個寫得很好的常見問題 – 2010-03-02 22:40:05

+0

我很高興,如果有幫助 - 它確實表明,有必要在每一刻。 – 2010-03-02 23:28:12

0

您需要使用正確的char代碼:&lt;和&gt;。

你會想surreound整個System.Collections.Generic.List <牛逼><see cref="..."/>標籤。

其實我不得不使用上述標籤才能正確地寫這個答案:)

相關問題