Writing a “Hello, World!” Program
The “Hello, World” program in the C# programming language is one of the most basic, simple starter programs that C# users can create in any supported programming language. To explain or introduce the basic syntax and structure of most programming languages, you can create a program called “Hello, World” as a first step.

So, let’s learn more about how to create the “Hello, World” program in the C# programming language.
- Steps to create the “Hello, World” program in C# Console.
- First, create a new C# console application.
- If C# users are using Microsoft Visual Studio or a popular C# IDE (such as Visual Studio Code), create a new project and select Console App as the current template.
- If C# users are using the command line with the CLI in the .NET Framework, run it first.
dotnet new console -n HelloWorldProg
cd HelloWorldProg
Write a C# program. A basic C# program will primarily include these features.
- using System; – This C# program imports the namespace function into the System program, which allows the C# programmer to create console CUI (character user interface)-based classes.
- namespace – C# user-defined program source code will be defined within a namespace, and it is commonly used to organize or group program source code.
- class – This is the main program class, which stores or processes the entire program logic as a structure within a class.
- Main() method – This is the first entry point for a C# program. This is where the C# program execution begins.
- Console.WriteLine() – This is a function method that helps the C# user print text output messages to the console screen.
C# Hello, World program source code.
using System; // Here it is used to import the System namespace to access Console class features
namespace HelloWorldProg // Here we define a namespace library
{
class HelloWorldProg // Here we define a class named HelloWorldProg
{
static void Main(string[] args) // Here we define a Main program method for entry point
{
Console.WriteLine(“Hello, World to the C# programming language”); // Here it prints the “Hello, World to the C# programming language” statement to the console screen
}
}
}
C# Hello, World program source code explanation.
- using System; – This allows the user to access Console-like class features in a C# program without having to specify the full namespace (System.Console.WriteLine) statement.
- namespace HelloWorldProg – This defines a namespace HelloWorldProg in a C# program to group or organize your program source code. This is especially helpful when a C# program project grows to a large number of lines of source code.
- class HelloWorldProg – Here, a Main class is created in the HelloWorldProg class, in which the Main() method function is defined as the entry point for the HelloWorldProg application.
- static void Main(string[] args) – This is the entry point or starting point for the C# console application. When you run the program in a C# program, the actual program execution begins from here. Command-line arguments can be passed using the program variable argument args parameter. However, for this simple BASIC program, we don’t officially need these methods and functions yet.
- Console.WriteLine(“Hello, World to the C# programming language”); – This prints the text message “Hello, World to the C# programming language” to the console line of the C# program.
Running a basic program in the C# programming language.
If C# programmers are using IDE software like Microsoft Visual Studio, C# users can simply click the Run button menu (or press the F5 key on the keyboard), and your current program will immediately execute, displaying your desired program output in the console window.
If you’re using the command line with the .NET CLI (Command Line Interface), follow the steps below.
- First, open a command prompt or terminal application window on your computer.
- Now, open your project folder using the cd command directory.
- Now, run your created program with the proper syntax.
