I'm sure it's a stupid question with an obvious answer, but I just can't figure it out. I'm practicing C# in VS Code, and putting all of my projects in a folder. Now when I try to test the start of my second program using "dotnet run", the terminal keeps trying to access the first project, not the one that's open.
"AdditionCalc.cs(7,17): error CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. [C:\Users\dylan\Desktop\C# practice\C# practice.csproj]" is the error message i get. "AdditionCalc.cs" is my first project, where I made a simple addition calculator.
using System;
namespace Practice
{
class Calculator
{
static void Main(string[] args)
{
string str1;
string str2;
int number1;
int number2;
Console.WriteLine("Enter Number One");
str1 = Console.ReadLine();
Console.WriteLine("Enter Number Two");
str2 = Console.ReadLine();
number1 = Int32.Parse(str1);
number2 = Int32.Parse(str2);
int answer = number1 + number2;
Console.WriteLine("Those two numbers added up is: " + answer);
string fivehundo = (answer >=500) ? "That number is bigger than 500" : "That number is smaller than 500";
Console.WriteLine(fivehundo);
}
}
}
This is my first Project
using System;
namespace Test {
class NumberGuesser {
static void Main(string[] args){
Random rnd = new Random();
int number = rnd.Next(1, 11);
Console.WriteLine(number);
}
}
}
this is my second project, where the user will guess a number and each time the console will return if the actual number is higher or lower than the one entered.
Do i specifically have to save these files in completely separate places and create a new console every time? Or is it that I have to open the file in a specific way? Help is greatly appreciated, and I know it's probably a stupid question and I'm overlooking something very basic