如何在XML注释中添加List类型代码示例?

Nee*_*n K 4 c# xml-documentation

我使用了以下XML评论,

    /// <example> 
    /// This example shows how to use <see cref="SampleCollection"/> property.
    /// <code>
    /// class TestClass 
    /// {
    ///      List<string> collection = new List<string>();
    ///      collection.Add("Column1");
    ///      collection.Add("Column2");
    ///      this.SampleCollection = collection;
    /// }
    /// </code>
    /// </example>        
    public List<string> SampleCollection
    {
        get;
        set;
    }
Run Code Online (Sandbox Code Playgroud)

但它有以下警告错误,

关于'SampleCollection'的XML注释格式错误 - '结束标记'代码'与开始标记'字符串'不匹配.

因为List定义有<string>.所以它认为是XML标签.

有什么方法可以解决这个问题吗?

SLa*_*aks 5

使用CDATA块在XML中嵌入原始文本:

<![CDATA[
List<string> ...
]]>
Run Code Online (Sandbox Code Playgroud)