C# Hello World Program

C# Hello World Program

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!");


Hello, World!

Working of the "Hello, World!" Program

  1. using System;
    This line includes the System namespace, which contains fundamental classes for input and output operations.
  2. class Program
    This line defines a class named Program. In C#, all code must be contained within a class.
  3. static void Main()
    This line defines the Main method, which is the entry point of the program. The static keyword means this method belongs to the class itself rather than an instance of the class. The void keyword indicates that the method does not return a value.
  4. {
    This opening brace marks the beginning of the Main method's body.
  5. Console.WriteLine("Hello, World!");
    This line prints the string "Hello, World!" to the console. The WriteLine method is part of the Console class.
  6. }
    This closing brace marks the end of the Main method's body.
  7. }
    This closing brace marks the end of the Program class.