In this tutorial, we will learn how to write comments in C# language. We will go through the different types of comments and how to use them in a program.
Comments are non-executable statements that are used to explain and document the code. They help improve the readability of the code and make it easier for others to understand. Comments can also be used to temporarily disable code during testing and debugging.
The syntax to define comments in C# is:
// Single line comment
/* Multi-line comment
continues here */
//
and continue to the end of the line.using System;
class Program {
static void Main() {
// Print Hello, World! to the console
Console.WriteLine("Hello, World!");
}
}
Hello, World!
/*
and end with */
.using System;
class Program {
static void Main() {
/* Print Hello, World! to the console
This is a multi-line comment */
Console.WriteLine("Hello, World!");
}
}
Hello, World!