Microsoft Visual Studio Community 2022 (64-bit) - Version 17.9.7

PeeJay48 0 Reputation points
2024-05-23T03:26:02.4566667+00:00

I am using C# from the above.

For a simple one file console app, I get a compile error saying "ProgA (namespace) already contains a Program class." It does not - there is just 1 file with a single definition internal class Program put there during file creation. There is a similar message for Main.

Why does C# think these have been duplicated.

Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,316 Reputation points Volunteer Moderator
    2024-05-23T04:37:07.46+00:00

    You don’t show your code, nor identify the .net version. so we can only guess. See rules for defining Main and determine which one you broke, though you appear to have defined the class Program twice.

    https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/main-command-line

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.