66

Which C# XML documentation comment tag is used for the literals true, false and null?

In Microsoft's own documentation, these literals appear in bold text. For example, the documentation for the property ArrayList.IsFixedSize appears as:

true if the ArrayList has a fixed size; otherwise, false. The default is false.

None of Microsoft's Recommended Tags seem to apply to this situation. The best fit appears to be <c>, however <c>true</c> appears as true when the documentation is rendered by Doxygen.

However, using <b>true</b> with Doxygen yielded bold text as I surmised that it might. But that leaves me wondering about the portability of using standard HTML tags with other documentation generation tools such as Sandcastle and GhostDoc.

DavidRR
  • 18,291
  • 25
  • 109
  • 191

2 Answers2

81

You should use the <see langword="true"/> entry so that it works right for whatever language is being used.

phoenix
  • 7,988
  • 6
  • 39
  • 45
Gargoyle
  • 9,590
  • 16
  • 80
  • 145
  • In Microsoft's updated documentation on the page **Recommended XML tags for C# documentation comments**, see the topic [Generate links and references](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/recommended-tags#generate-links-and-references) which states for **see**: `langword="keyword"`: A language keyword, such as `true` or one of the other valid [keywords](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/). – DavidRR May 05 '23 at 21:49
19

Per GhostDoc's behavior, <c>true</c> is the correct answer. I've voted up saravanan's comment now that I've been able to confirm it.

Xpleria
  • 5,472
  • 5
  • 52
  • 66
Jack Pines
  • 289
  • 4
  • 12