Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing generic class eg Table<String> in xml comments in visual studio

I know this maybe a basic question but I just can't seem to find the answer anywhere.

I have a class like this

Table<T>
{}

then I have some code that uses the above class that I would like to comment I would like to be able to do something like:

/// <summary>
/// blah blah blah Table<String>
/// </summary>

But I can't use the angle bracket in the comment as it thinks it's a tag and when the help shows up it just has an error about no end tag for .

How do I show generic classes in comments in Visual Studio.

like image 210
Nathan W Avatar asked Jan 12 '09 01:01

Nathan W


People also ask

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 is the comment syntax for C #s XML based documentation?

XML documentation comments - document APIs using /// comments | Microsoft Learn.


2 Answers

You need to use XML entities (sort of escape sequences): &lt; for < and &gt; for >. Intellisense will display < as and > correctly.

EDIT: Here's a cheat sheet listing of all of the XML entities:

&lt;   for <
&gt;   for >
&amp;  for &
&quot; for "
&apos; for '
like image 168
Tamas Czinege Avatar answered Sep 28 '22 01:09

Tamas Czinege


try using an &lt; instead of a <

like image 30
Tim Howland Avatar answered Sep 28 '22 02:09

Tim Howland