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
Post a Comment