Single Line Comment in C#

Single line comment in C#. In this program we can learn how to include the single line comments in C sharp. Comments can be used to explain and improve the readability of C# code. When evaluating alternative code, it can also be used to prevent execution. Two forward slashes (//) begin single-line comments. C# ignores any text between / and the end of the line (will not be executed).

using System;

namespace Main
class Program
static void Main(string[] args)
// This is a comment
Console.WriteLine("Hello World");

Hello World

Purpose of Using System in C#

In C#, namespaces are used to arrange a large number of classes so that the program can be easily managed. System is used in a basic C# program. Console is a class that belongs to the System namespace. We must use namespacename to get the class of a namespace.

Uses of Static void main(string[] args)

The Main method describes what the class does when it is run and creates additional objects and variables. Because it is accessible to run when the C# program starts, a main method is static. It is the program’s starting point, and it runs without even creating a class object.

Namespace in C#

The purpose of a namespace is to provide a means to keep one set of names from interfering with another. No conflict exists between class names declared in different namespaces.