All rules
IDE0211Language rules (code-block preferences)

Convert to 'Program.Main' style program

Convert to 'Program.Main' style program

Microsoft docs

Description

This rule flags the use of top-level statements instead of a Main method entry point in a project.

Example

// Code with violations (entire file).
Console.WriteLine("Hello world.");

// Fixed code.
internal class Program
{
    private static void Main(string[] args)
    {
        Console.WriteLine("Hello world.");
    }
}

Configurable options

Vote for the value each option should take in the generated .editorconfig.

csharp_style_prefer_top_level_statements
default: true
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0