C# Hello World Example

Language:
C#
24 views
0 favorites
8 days ago

Code Implementation

C#
// Define the namespace
using System;

namespace HelloWorld
{
    // Define the class
    class Program
    {
        // Program entry point
        static void Main(string[] args)
        {
            // Output Hello World
            Console.WriteLine("Hello, World!");
        }
    }
}

C# is an object-oriented language developed by Microsoft, commonly used for Windows applications and Unity game development

#Beginner

Snippet Description

Run Instructions (Beginner):

  • Install the .NET SDK (available from dotnet.microsoft.com)
  • Save the code as HelloWorld.cs
  • Compile: csc HelloWorld.cs
  • Run: On Windows it's HelloWorld.exe, on Linux/macOS it's ./HelloWorld

Alternatively, using the .NET CLI:

  • dotnet new console -n HelloWorld
  • cd HelloWorld
  • dotnet run

FAQ (2)

Comments

Loading...