10

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

Community
  • 1
  • 1
Tony
  • 12,405
  • 36
  • 126
  • 226

4 Answers4

13

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.

oleksii
  • 35,458
  • 16
  • 93
  • 163
  • 1
    no. If inside the summary, [``](http://msdn.microsoft.com/en-us/library/f8hahtxf) should be used. [``](http://msdn.microsoft.com/en-us/library/f8hahtxf) is for code that appears *outside* the summary. Take a look at [the example on MSDN](http://msdn.microsoft.com/en-us/library/9w4cf933). – Adam Sep 06 '12 at 16:56
6

To add an example, use the

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

tags.

Osiris
  • 489
  • 3
  • 14
  • My formatting was off. I'm not sure how to get < example> to show in the answer without adding a space in the tag. – Osiris Sep 06 '12 at 16:54
2

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.

albert
  • 8,285
  • 3
  • 19
  • 32
Nicholas Carey
  • 71,308
  • 16
  • 93
  • 135
0

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>
Aardvark
  • 1,264
  • 1
  • 12
  • 21