A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/c-sharp/c-sharp-hello-world/ below:

C# Hello World - GeeksforGeeks

C# Hello World

Last Updated : 11 Jul, 2025

The Hello World Program is the most basic program when we dive into a new programming language. This simply prints "Hello World!" on the console. In C#, a basic program consists of the following:

Example: Hello World program in C#.

C#
// 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 prevent the screen from 
            // running and closing quickly 
            Console.ReadKey(); 
        } 
    } 
} 

Explanation:

Executing C# Program

There are generally three ways to compile and execute a C# program.

Now follow the below steps:

Step 1: Open a command prompt and create an empty .NET project using the following command:

dotnet new console -o <Project-Name>

In the <Project-Name> we can provide the name of the project which we want to build in this example as shown below. Here, we use the project name as HelloWorld. This command will create an empty project template with all the necessary packages required to run the .NET project.

This is the complete folder structure which is created using the above command.

The Program.cs is the entry point in this file the C# code is written we can not directly open this file but we can open it in any IDE like Visual Studio or Visual Studio Code this is the default code which is written inside the program.cs file as shown in the below image

This is a simple program we can run it using the following command mentioned in the below steps.

Step 2: Now we need to build the project using the command mentioned below.

Navigate to the project directory:

cd HelloWorld

Build the project using:

dotnet build

Step 3: Now to see the output run the command mentioned below.

dotnet run

This will execute the default Program.cs file and display output in the console.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4