C# "Hello, World!" Program

Hello World!

A "Hello, World!" program is usually the first program written by people who are beginners in writing codes. It is a very simple program which displays the message "Hello, World!". It is probably the simplest program to illustrate a few basic syntaxes of a programming language. This article covers the C# program to print "Hello World!".

1. Algorithm for "Hello, World!"

1. Print "Hello, World!"

2. Pseudocode for "Hello, World!"

1. Procedure print():

2. Print "Hello, World!"

3. End Procedure

3. Time complexity for "Hello, World!"

Time Complexity: O(1)

4. C# Program & output for "Hello, World!"

Code has been copied
using System;
// Declare namespace named "Print"
namespace Print {
    // class named "Program"
    class Program {
        // main method
        static void Main(string[] args) {
            //display hello world
            Console.WriteLine("Hello, World!");
            // wait for user to press any key


Hello, World!

  • using System;: This line imports the System namespace which provides fundamental classes and base classes for C# applications. It includes the Console class, which is used to interact with the console for input and output.
  • namespace Print: This declares a custom namespace named Print. Namespaces are used to organize code, and they help prevent naming conflicts.
  • class Program: This declares a class named Program within the Print namespace.
  • static void Main(string[] args): This is the Main method, which is the entry point for C# program. When the program is executed, it starts here. It takes an array of strings (args) as an argument. This method is marked as static, meaning it can be called without creating an instance of the Program class.
  • Console.WriteLine("Hello, World!");: This line uses the Console.WriteLine method to display Hello, World! on the console. Console.WriteLine also appends a newline character after the text, so the cursor moves to the next line.
  • Console.ReadKey();: This line waits for the user to press any key before the program exits. It's often used to keep the console window open so the output can be seen before it closes.