DEV Community

KeigoNakano
KeigoNakano

Posted on

Main method in C#9 and later

In C#9 and later, it is not necessary to explicity include Main() in a console application.

In C#9 and later

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
Enter fullscreen mode Exit fullscreen mode

Prior to C#9

using System;
name MyApp // Note: actual namespace depends on the project name.
{
   internal class Program
  {
      static void Main(string[] args)
      {
          Console.WriteLine("Hello World!")
      }
   }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
respect17 profile image
Kudzai Murimi

Thanks a lot!