C# XML /// Comments, where does <returns></returns> tag show up?

When you see the method in View >> Object Browser

For e.g. you will see something like this:

private int GetColumnIndex(Microsoft.Office.Interop.Excel.Worksheet worksheet, string columnName, int rowIndex, int startColumnIndex)
    Member of MyAddIn.CommandHandlers.CommandHandler

Summary:
Returns the column index with specified name and in specified row

Parameters:
worksheet: Target worksheet
columnName: Column name to find
rowIndex: Row index in which to search the column
startColumnIndex: Start index of the column

Returns:
The index of column if found, else returns 0

If you generate API documentation from the comments, it will show up in the Return value section, as seen here, right before the Remarks section.


When you choose to build an XML documentation file on compilation, then everything that is contained in the XML documentation comments gets copied over into that file. Programs like Sandcastle then can build HTML documentation akin to the MSDN from that.

It doesn't show in Visual Studio's own IntelliSense, as far as I know. But that's no excuse not to write something there :-). ReSharper's Ctrl+Q for example does show it.


For those that may come trying to find something. This might not be the best approach but IMHO it does make more understandable what a method does while hovering over the method name.

        /// <summary>
        /// Adds a new post given the mapped PostDTO and userId <br></br><br></br>
        /// <b>Returns</b> the newly created object, otherwise null.
        /// </summary>
        /// <param name="postDTO"></param>
        /// <param name="userId"></param>
        PostDTO addPost(PostDTO postDTO, long userId);

This way you can see something in VS (at least in VS 2019) like in next image, which in my experience, when trying to understand code made by others, at least you can tell what to expect, whether an actual object or null, or whatever scenario.

enter image description here

I hope it may be useful for others.


The other sections (basically anything exception summary) won't appear in intellisense. They are only intended to appear in documentation generated from the XML, using a tool like Sandcastle.