sloppycode.net
XML Comment Cheat Sheet
.NET XML Documentation guide + cheat sheet


Download .snippet files for these examples

If you like to give your code meaningful XML comments and want the output to look vaguely like the MSDN documentation, then below are a few templates you can use for consistency.These aren't "how to write XX method" but just how the textual descriptions appear in most of the .NET framework documentation, for example you'll find 'Raises the ... event' in almost all event descriptions.

The download above the examples below in snippet format (for VS.NET 2005/2008) that autocompletes various methods. To use the .snippet download, copy it to your 'C:\Users\\Documents\Visual Studio 2008\Code Snippets\Visual C#' directory and then type eqts inside the code editor in Visual Studio.

Make sure you click 'view plain' to get the properly formatted text, as some lines span over the textarea.

Embedding tags:
If you need to put a tag inside you description. There's no need to do this for CDATA. New Paragraphs
You will need to wrap descriptions in these tags if you want it to be readable instead of a wall of text. Standard constructor
Standard event and raising the event
Embedding links to other classes
Embedding links to other class properties/methods
Embedding an example
Remember to use CDATA or you'll get documentation errors. Linking to external documentation
From another file (for large amounts of documentation that makes it hard to read the source file) then the XML file would be: Your method catches an exception
Exception class headers
Overriding Hashcode
As found in MSDN Overriding ToString
As found in MSDN Overriding Equals
As found in MSDN Links
Sandcastle for building web/htmlhelp documentation from the .xml files
GUI for Sandcastle
MSDN docs for .NET XML documentation (local)
MSDN docs for .NET XML documentation (online)

› Home
› C#
› Snippets
› Articles
› Tools
› Taglines
› ASP
› Dictionary Object
› FSO
› Unix cheat sheet
› Gaming
› CSS
› Yak
› Umbraco
› About
› Contact
› Privacy
› Projects
› Search