hello world c# code example

Example 1: hello world program in c#

// Hello World! program
namespace HelloWorld
{
    class Hello {         
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello World!");
        }
    }
}

Example 2: c# hello world

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, world!");

            // To prevents the screen from  
            // running and closing quickly 
            Console.ReadLine();
        }
    }
}

Example 3: hello world c#

Console.WriteLine("Hello World!");

Example 4: hello world c#

Console.WriteLine("Hello, World!");

Example 5: hello world c#

using System;

namespace HelloWorld
{
  class Program
  {
    static void Main(string[] agrs)
    {
      Console.WriteLine("Hello World");
      
      // Wait before closing
      Console.ReadKey();
    }
  }
}