Document Comments in .NET

 

Whenever want to document our C# code in XML, we have to enter triple slash (///) code comment notations. Then it displays required XML tags which allows to enter our comments.

 

C# defines different XML tags to enter comments as shown below.

 

<c>  -   - Indicates that the following text should be displayed in a specific code font

<code>  -  Indicates multiple lines should be marked as code

<example>  -  Mocks up a code example for the item you are describing

<exception>  -  Documents which exceptions a given class may throw

<list>  -  Inserts a list or table into the documentation file

<param>  -  Describes a given parameter

<paramref>  -  Associates a given XML tag with a specific parameter

<permission>  -  Documents the security constraints for a given member

<remarks>  -  Builds a description for a given member

<returns>  -  Documents the return value of the member

<see>  -  Cross-references related items in the document

<seealso>  -  Builds an “also see” section within a description

<summary>  -  Documents the “executive summary” for a given member

<value>  -  Documents a given property

 

If we enter triple slash(///) it displays the comments as shown below.

       

        ///<summary>

        ///

        ///</summary>

        ///<param name="iId"></param>

        ///<returns></returns>

        private string GetName(int iId)

        {

            return "Raj";

        }

 

Once you enter all required comments we can document all these comments into one XML file. To document all XML comments into one file, right click on project and select properties.

Select Build Option => Go to Ouput section => select "XML documentation file" option and enter File Name as shown below

 

 

Now execute the project and all the comments are saved to mentioned file at mentioned path.

 

                                                                                                                   CSharpComments.zip (22.28 kb)