Hello World Program in C#
In this tutorial, we will learn how to write a Hello World program in C# language. We will go through each statement of the program.
C# Program
using System;
class Program {
static void Main() {
Console.WriteLine("Hello, World!");
}
}
Output
Hello, World!
Working of the "Hello, World!" Program
using System;
This line includes the System namespace, which contains fundamental classes for input and output operations.class Program
This line defines a class named Program. In C#, all code must be contained within a class.static void Main()
This line defines the Main method, which is the entry point of the program. Thestatic
keyword means this method belongs to the class itself rather than an instance of the class. Thevoid
keyword indicates that the method does not return a value.{
This opening brace marks the beginning of the Main method's body.Console.WriteLine("Hello, World!");
This line prints the string "Hello, World!" to the console. TheWriteLine
method is part of the Console class.}
This closing brace marks the end of the Main method's body.}
This closing brace marks the end of the Program class.