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() function and both files contain two different programs.
Code in the Addition.cs file:
using System;
namespace Example
{
class Addition
{
static void Main(string[] args)
{
int sum = 3 + 2;
Console.WriteLine(sum);
}
}
}
Code in the Substraction.cs file
using System;
namespace Example
{
class Substraction
{
static void Main(string[] args)
{
int sub = 3 - 2;
Console.WriteLine(sub);
}
}
}
I want to test both the programs one by one, but when I do
"dotnet run"
It fails with the above error.
I know because of two main() functions (entry points) in the same project is creating this error, but this can be overcome in Visual Studio by setting up a startup project.
I am using Visual Studio Code, where I am unable to set up a startup project.
Is there a way to set up an entry point for a C# project in Visual Studio Code?