Valid variant of Main() in C#



The Main method is the entry point for all C# programs. It states what the class does when executed.

The valid variant of Main() is −

static void Main(string[] args

Here,

  • static − the object is not needed to access static members

  • void − return type of the method

  • Main − entry point for any C# program. Program execution begins here.

  • string[] args − for command line arguments in C#.

Example

Here is an example −

using System; namespace Program {    public class Demo {       public static void Main(string[] args) {          Console.WriteLine("Welcome!");          Console.ReadKey();       }    }   }
Updated on: 2020-06-22T12:01:04+05:30

741 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements