"Verified" ~ "verified*" ~ "verified^" Study Cube Learning: C# Tutorial 2 - Comments in C#

Thursday, May 21, 2020

C# Tutorial 2 - Comments in C#

Comment in C# is basically used for explaining programs and lines of code do. Comments are ignored by the compiler. There are three types of comments.

1- Single line comment - It is used for commenting the single line of code.
      // Single line Comment
 
2- Multi-line comment - It is used for commenting the multiple lines of code. 
      /* Multiple 
      line of code comment */

C# Program to explain the single line and multiline comments -

class Hello {    
    // Single Line Comment -- Function to print Message 
    public static void PrintMessage(string message) 
    { 
        Console.WriteLine (message); 
    }       
    // Main function 
    static void Main(string[] args) 
    {           
        /* Multiline Comment -- 
           Define a variable of 
           string type and assign 
           value to it*/
        string msg = "Study Cube Learning";           
        PrintMessage (msg);           // Calling function 
    } 

3- XML Comment - It is used for commenting the multiple lines of code for better understanding the program does.

class Hello {    
/// <summary>
/// Method to show string message
///</summary>
///<pram name =“message”></param>
    public static void PrintMessage (string message) 
    { 
        Console.WriteLine (message); 
    }           
    static void Main(string[] args) 
    {           
        string msg = "Study Cube Learning";           
        PrintMessage (msg); 
    } 



No comments:

Post a Comment

Choose the Right Graphic Designer

 Picking a decent visual originator is critical in the improvement of your image. There are many visual originators around and everybody you...