14. C# - Main Method

Main method is entry point for console and windows apps.

Allows running code within a Main() function automatically.

Main method/function must be inside a class.


Example:

structs or whatever above


class Program {

        static void Main() {

            whatever here

        }

}

// using main method can get by the top level statements error.


Types of Main methods:

//parameterless Main() methods
public static void Main() { }
public static int Main() { }
public static async Task Main() { }
public static async Task<int> Main() { }

//Main() methods with string[] parameter
public static void Main(string[] args) { }
public static int Main(string[] args) { }
public static async Task Main(string[] args) { }
public static async Task<int> Main(string[] args) { }



Comments

Popular posts from this blog

2. FreeCodeCamp - Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges

20. Data Analytics - Analyze Data to Answer Questions - Week 1

3. Algorithms - Selection Sort