How to add sample list type code to XML comments?

I used below XML comment,

    /// <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;
    }

But it has the following warning error:

The XML comment for 'SampleCollection' has poorly formed XML - the 'End tag' code 'does not match the start tag' string '. ''

because the definition of the list has <string>. Therefore, he considered this an XML tag.

Is there any way to resolve this?

+4
source share
1 answer

Use the CDATA block to insert raw text into XML:

<![CDATA[
List<string> ...
]]>
+5
source

Source: https://habr.com/ru/post/1625250/


All Articles