Comments

suggest change

Using comments in your projects is a handy way of leaving explanations of your design choices, and should aim to make your (or someone else’s) life easier when maintaining or adding to the code.

There are a two ways of adding a comment to your code.

Single line comments

Any text placed after // will be treated as a comment.

public class Program
{
    // This is the entry point of my program.
    public static void Main()
    {
        // Prints a message to the console. - This is a comment!
        System.Console.WriteLine("Hello, World!"); 

        // System.Console.WriteLine("Hello, World again!"); // You can even comment out code.
        System.Console.ReadLine();
    }
}

Multi line or delimited comments

Any text between /* and */ will be treated as a comment.

public class Program
{
    public static void Main()
    {
        /*
            This is a multi line comment
            it will be ignored by the compiler.
        */
        System.Console.WriteLine("Hello, World!");

        // It's also possible to make an inline comment with /* */
        // although it's rarely used in practice
        System.Console.WriteLine(/* Inline comment */ "Hello, World!");
  
        System.Console.ReadLine();
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Comments and regions:
* Comments

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
55 Comments and regions
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script