Friday, 1 September 2017

How to Use Comments in C#

 How to Use Comments in C#

The C# comments are statements that are not executed by the compiler. The comments in C# programming can be used to provide explanation of the code, variable, method or class. By the help of comments, you can hide the program code also.

There are two types of comments in C#.

  •   Single Line comment
  •   Multi Line comment

C# Single Line Comment

    using System; 
       public class CommentExample 
        { 
           public static void Main(string[] args) 
            { 
                int x = 10;//Here, x is a variable   
                Console.WriteLine(x); 
            } 
        } 

    C# Multi Line Comment
   
     using System; 
           public class CommentExample 
            { 
               public static void Main(string[] args) 
                { 
                    /* Let's declare and 
                  print variable in C#. */  
                    int x=20; 
                    Console.WriteLine(x); 
                } 
            } 

Post a Comment

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search