Skip to content

Commit

Permalink
Rework Main access modifier part
Browse files Browse the repository at this point in the history
  • Loading branch information
vernou committed Jun 20, 2024
1 parent dd7f7d3 commit dce4d5c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ For more information, see [Top-level statements](top-level-statements.md).
- The `Main` method is the entry point of an executable program; it is where the program control starts and ends.
- `Main` must be declared inside a class or struct. The enclosing `class` can be `static`.
- `Main` must be [`static`](../../language-reference/keywords/static.md).
- `Main` can have a [`public`](../../language-reference/keywords/public.md), [`protected`](../../language-reference/keywords/protected.md), [`private`](../../language-reference/keywords/private.md), [`internal`](../../language-reference/keywords/internal.md), [`protected internal`](../../language-reference/keywords/protected-internal.md) and [`private protected`](../../language-reference/keywords/private-protected.md) access modifier. If not specified, it receives the default access of `private`.
- `Main` can have any [access modifier](../../programming-guide/classes-and-structs/access-modifiers.md) (except `file`).
- `Main` can either have a `void`, `int`, `Task`, or `Task<int>` return type.
- If and only if `Main` returns a `Task` or `Task<int>`, the declaration of `Main` may include the [`async`](../../language-reference/keywords/async.md) modifier. This specifically excludes an `async void Main` method.
- The `Main` method can be declared with or without a `string[]` parameter that contains command-line arguments. When using Visual Studio to create Windows applications, you can add the parameter manually or else use the <xref:System.Environment.GetCommandLineArgs> method to obtain the command-line arguments. Parameters are read as zero-indexed command-line arguments. Unlike C and C++, the name of the program is not treated as the first command-line argument in the `args` array, but it is the first element of the <xref:System.Environment.GetCommandLineArgs> method.
Expand Down

0 comments on commit dce4d5c

Please sign in to comment.