'CS8804: Cannot specify /main if there is a compilation unit with top-level statements [closed]

searching "C# compilation unit" does not reveal any useful results around the internet



Solution 1:[1]

You have written some statements outside of any method or class. These statements are interpreted as top-level statements. Top-level statements are automatically enclosed in a compiler generated main method. Since you cannot add another main method, you can use top-level only once.

Resolution: move these top-level statements in a method inside a class.

See:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1