Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I put code examples in .NET XML comments?

What tags can I use for putting code examples in .NET /// XML comments?

like image 401
DLauer Avatar asked Aug 12 '09 21:08

DLauer


People also ask

How do you add comments in XML?

The syntax for adding XML comments in your code is triple slashes /// followed by one of the supported XML tags.

How do I add comments to XML in Visual Studio?

To insert XML comments for a code element Do one of the following: Type /// in C#, or ''' in Visual Basic. From the Edit menu, choose IntelliSense > Insert Comment. From the right-click or context menu on or just above the code element, choose Snippet > Insert Comment.

What are XML comments in C#?

C# documentation comments use XML elements to define the structure of the output documentation. One consequence of this feature is that you can add any valid XML in your documentation comments. The C# compiler copies these elements into the output XML file.

What sequence of characters indicates the start of an XML style documentation comment in C# code?

The use of XML doc comments requires delimiters that indicate where a documentation comment begins and ends. You use the following delimiters with the XML documentation tags: /// Single-line delimiter: The documentation examples and C# project templates use this form.


1 Answers

Try using the <example> tag.

/// <example>
/// <code>
/// // create the class that does translations
/// GiveHelpTransforms ght = new GiveHelpTransforms();
/// // have it load our XML into the SourceXML property
/// ght.LoadXMLFromFile(
///  "E:\\Inetpub\\wwwroot\\GiveHelp\\GiveHelpDoc.xml");
/// </code>
/// </example>

I got the above example from here.

like image 145
Jason Evans Avatar answered Oct 19 '22 22:10

Jason Evans