Question

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

Was it helpful?

Solution

You can use <code> and <c> XML tags

/// <summary>
/// ...
/// <c>Place your code here</c>
/// </summary>
/// <code>
/// More code here
/// </code>

Per comment, in the <summary> you can use a <c> tag and outside <summary> you can use a <code> tag.

OTHER TIPS

To add an example, use the

<example> 
<code>
Put your example here.
</code>
</example>

tags.

See MSDN:

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top