Visual Studio Code: “Program has more than one entry point defined”

前端 未结 1 1406
别那么骄傲
别那么骄傲 2020-12-16 03:19

I created a C# project using Visual Studio Code. This project contains two .cs files, Addition.cs and Substraction.cs. Both files contain a main()

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 04:11

    If both entry points are in the same project, setting the startup project wouldn't do anything anyway. You need to set the startup object.

    This can be done in the project properties dialog in a full version of Visual Studio (look for "Startup object" under Application), or in the .csproj file by setting Project/PropertyGroup/StartupObject:

    Example.Addition
    

    Alternatively consider using a single Main() entry point which takes a command-line argument.

    0 讨论(0)
提交回复
热议问题