Hello, World
Here is a simple "Hello World" program in C#:
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
}
Steps to Compile and Build
Save the code: Save the above code in a file named
Program.cs
.Open a terminal: Navigate to the directory where
Program.cs
is saved.Compile the code: Use the
csc
(C# compiler) to compile the code. Run the following command:csc Program.csRun the executable: After compilation, an executable file named
Program.exe
will be created. Run it using:Program.exe
This will output:
Hello, World!
Last modified: 01 January 2025