Open In App

Hello World in C#

The Hello World! program is the most basic and first program when you dive into a new programming language. This simply prints the Hello World! on the output screen. In C#, a basic program consists of the following:

Example:

// C# program to print Hello World! 
using System; 

// namespace declaration 
namespace HelloWorldApp { 
    
    // Class declaration 
    class Geeks { 
        
        // Main Method 
        static void Main(string[] args) { 
            
            // statement 
            // printing Hello World! 
            Console.WriteLine("Hello World!"); 
            
            // To prevents the screen from 
            // running and closing quickly 
            Console.ReadKey(); 
        } 
    } 
} 

Output
Hello World!

Explanation:

How to run a C# Program?

Generally, There are 3 ways to compile and execute a C# program as follows:


Article Tags :
C#