Reputation: 1071
I want to add XML code in -NET C# XML documentation, i found this help: https://stackoverflow.com/a/11030588/2825284 but not work
/// <summary>
/// My comentary:
/// <code>
/// <MyXmlCode>
/// <XmlNode Atribute="34"/>
/// </MyXmlCode>
/// </code>
/// </summary>
Upvotes: 1
Views: 84
Reputation: 5607
Your example code contains reserved XML characters that need to be escaped. These characters and their escape sequences are:
< ... <
> ... >
& ... &
So your comment needs to be:
/// <summary>
/// My comentary:
/// <code>
/// <MyXmlCode>
/// <XmlNode Atribute="34"/>
/// </MyXmlCode>
/// </code>
/// </summary>
Or, to make it more readable, use CDATA:
/// <summary>
/// My comentary:
/// <code><![CDATA[
/// <MyXmlCode>
/// <XmlNode Atribute="34"/>
/// </MyXmlCode>
/// ]]></code>
/// </summary>
BTW, our VSdocman contains the comment editor which produces CDATA. One drawback of CDATA is that Intellisense doesn't show it currently.
Upvotes: 1