How to place the code example in the XML comment?
-
30-06-2021 - |
Pregunta
I have a XML comment like that.
/// <summary>
/// Lorem ipsum
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
I'd like to place inside it a piece of the (multiline) code. How can I do that ?
Edit
Here's the info about multiline code Adding line breaks to comments for Intellisense
Otros consejos
To add an example, use the
<example>
<code>
Put your example here.
</code>
</example>
tags.
See MSDN:
- XML Documentation Comments (C# Programming Guide)
- Recommended Tags for Documentation Comments (C# Programming Guide)
One should note, though, that the XML documentation comments are just that—XML—and the compiler will process any valid XML tag: it's semantics are dependent on your documentation processor.
Annex E of ECMA 334: C# Language Specification aka ISO 23270: Information technology — Programming languages — C# specifies a standard set of XML documentation markup.
I'm not entirely sure what you're asking, but here's my best shot:
I typically place code examples inside an <example> </example>
tag.
/// <summary>
/// Lorem ipsum
/// </summary>
/// <example>
/// Put you're example here.
/// </example>
/// <param name="entity"></param>
/// <returns></returns>