7

我有這種方法,我試圖生成文檔。如何在文檔代碼中使用IEnumerable <String>

/// <summary> 
    /// This method demonstrates taking a Func as argument and perform that action(Func) on a list of strings.</summary> 
    /// <param name="listOfStrings"> ... </param> 
    /// <param name="ActionToPerformOnEach"> ... </param> 
    /// <returns>Returns an <see cref="IEnumerable{String}" /> which has elements that resulted due to the Func action </returns> 
    public static IEnumerable<String> ActOnListWithFunc(List<string> listOfStrings, Func<string, string> ActionToPerformOnEach) { 
     foreach (string s in listOfStrings) { 
      string actedString = ActionToPerformOnEach(s); 
      yield return actedString; 
     } 
    } 

這會產生這樣的(僅返回值部分所示)文檔

Return Value 
Type: IEnumerable<String> 
Returns an IEnumerable<T> which has elements that resulted due to the Func action 

凡我所描述的方法的返回值,我想用IEnumerable的<串>但如果你看它的描述,它正在生成IEnumerable <T>類型:(上面的第二行)雖然被正確拾取爲IEnumerable <字符串>。只是返回值的描述行不正確。

我們如何描述IEnumerable的<串>IEnumerable的<INT>或參數的說明任何其他特定枚舉類型或返回值,即betwween <PARAM> < /參數>或<回報> < /返回>被記錄的方法的標籤。

+0

可能重複[如何在XML文檔中引用泛型類和方法](http://stackoverflow.com/questions/532166/how-to -reference-generic-classes-and-methods-in-xml-documentation) –

+0

我已經在該方法的Returns屬性中使用了,但它沒有顯示特定的泛型類型串)。請查看發佈的第二個補丁的第三行。它讀取IEnumerable 而不是IEnumerable Jatin

回答

4

您可以使用<see cref="IEnumerable{String}">IEnumerable&lt;string&gt;</see>顯示適當的文本。但鏈接仍將IEnumerable<T>,因爲沒有具體的文檔IEnumerable<string>

+0

我認爲,鏈接到IEnumerable 可能是可以接受的,但這些字符實體(<和>)有點難看。但在任何情況下,您的解決方案都可以工作,並根據需要獲得IEnumerable 。在標記爲可接受的解決方案之前,我仍然會等待一段時間,尋找替代方案。 – Jatin

相關問題