C# Comments Example

C#Adding comments while coding is a very good practice.  Most of the times, we end up writing very lengthy code and at that time, just to remember what a particular block of code will actually do, we use comments.   The comments in C# code also important and helpful for other team members who are helping you in building your project.   The keyboard shortcut we use for putting comments in C# code is CTRL + K + C and to undo the comments is CTRL + K + U.   Just type the comments and then use the given keyboard shortcut to comment or undo the comment in C# code.   The another way of putting comments in C# code is by simply using two forwards slashes (//) before your comments.   The C# comments example is given below.

 

using System;

namespace comments
{
    class Program
    {
        static void Main(string[] args)
        {
            //This is a C# code comment example.

            Console.WriteLine("This is hello world");
        }
    }
}