XML Documentation in C#

In C#, we use XML Comments to create documentation of classes and their members. XML Documentation helps other programmers or developers to use your code (classes, functions and their members) easily by providing some useful information. XML Documentation starts with three slashes before the class or function to be documented.
 
Adding XML Documentation to a class:
Typing three slashes (///) before a class or function will create documentation automatically in Visual Studio. The documentation contains one or more documentation elements. Each element starts with a start tag (for example <summary>) and ends with an end tag (for example </summary>). Here is a list of a few elements with their description.
 
Element
Description
<summary>
Provide Description for Class, member and so on.
<param name=”i”>
Describe a parameter of a method
<returns>
Describe return type of a method
<value>
Describe value of a property

For example:

 
 
In the above example, when we type three slashes before a result method then it will automatically create three documentation elements, Summary (for the description of the class), a param tag for each parameter and a return tag for the method’s return type.
 
When we type or use Add class then IntelliSense in Visual Studio shows a Screen tip that we have added to the XML documentation element (<summary tag>) earlier.

Preview:
 
 

Up Next
    Ebook Download
    View all
    FileInfo in C#
    Read by 9.7k people
    Download Now!
    Learn
    View all