How to use method comments in C#

When hover on methods from existing libraries, you will see lots of descriptions. But you can do that to your own methods as well and here is how…

In this example we have a simple class which contains two simple static methods. Above them, you see our method comments. The best thing about it, is you do not have to write all of this… Simply select the line above the method and press “Slash” key on your keyboard three times and this arrangement will appear.

This example has two methods, but these are overloads rather than two different methods. So depending on which option is chosen, you will get different descriptions.

The Summary is the main description and as you can see depending on which implementation is hovered on, we see different descriptions. The same goes for the returns, which you can see bellow the description. Remember, if the method is void, there will be no returns entry.

Finally, if you get into the parameters, each one of them will have its’ own description. These are set with param entries and unlike the previous ones, these need to have parameter names specified.

--

--