Search

Tuesday, February 4, 2014
0 comments

Comments in c# console application

7:51 AMTuesday, February 4, 2014
Comments are non-executale statements. Generally created for making user-friendly application. If we talk about c# comments, there are three types.

first one single line second one is multi-line and last one is XML documentation comments. Look like

Single-line Comments   --- // (created through double slash)
Multi-line Comments  ---- /*   */  
XML Documentation comments --- ///

Note : Don't try to comment every line of code. Use comments only for code, which is difficult to understand.

If you want to create comment in c# application , you can use keyboard shortcut. CTRL+K with C for comment, CTRL+K with U for un-comment.

Lets create a simple application demo for understanding  all types of comments.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Addtwonumber qd = new Addtwonumber();

            //int number = 10;

            /*if (number == 10)
            {
                Console.WriteLine(number);


            }*/
        }
    }
  /// <summary>
  /// This class is designed for adding two number
  /// </summary>
    public class Addtwonumber
    {

    }
}
Code generate the following output
This example cover all types of comments. According to screen snap, you can better understand XML comments. If you don't use XML comment , before creating the class. Intellisense doesn't dispay the summary of the class. 

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top