Comments in c# console application

February 04, 2014 0 Comments

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)

  /// <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. 

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google