What are the different types of comments in C#?


There are three types of comments:

1.      Single line comments: It is used to comment on a single line like below:

          // Single Line Comments

2.      Multiline comments: It is used to comment on multiple lines at a time like below:

          /* Multiline

         Comment */

3.      XML Documentation Comments: By using “///” we can write the documentation of c# code. It uses XML elements to add comments like below:

         /// <summary>

         /// This is Test Class

         /// </summary>

         Class Test {

         }

We can write the XML documentation comment to methods alsp by using   <summary> tag for method description and <param> tag for parameter description like below:

  /// <summary>
            /// Method to Show
            /// </summary>
            /// <param name="text">Text to show</param>
            public static void Show(string text)
            {
 }

Post a Comment

0 Comments