Table of Contents

    C# Comments

    Understanding different types of comments in C# programming

    Types of Comments in C#

    1. Single-Line Comments

    Single-line comments are used to add brief comments on a single line. They begin with // and extend to the end of the line.

    // This is a single-line comment
    int x = 10; // This is an inline comment

    2. Multi-Line Comments

    Multi-line comments are used to add comments that span multiple lines. They begin with /* and end with */.

    /* This is a multi-line comment
       It can span multiple lines
       and is useful for longer explanations */
    int y = 20;

    3. XML Documentation Comments

    XML documentation comments are used to provide documentation for code elements. They begin with /// and are used to generate XML documentation files.

    /// 
    /// This method adds two integers
    /// 
    /// The first integer
    /// The second integer
    /// The sum of the two integers
    public int Add(int a, int b)
    {
        return a + b;
    }