C
C#17mo ago
Aimlatte

❔ which one how how should I fix this problem?

-dotnet run keep running program.cs but not my code -try setting startup file by Right-click on the project but can't find "Set as Startup Project." -try Open Solution Explorer by cliking View > Solution Explorer but can't find Explorer -try using keyboard shortcut Ctrl+Alt+L but nothing shows up either -try seurching for another version by going to view > Other Windows > Solution Explorer but can't find other windows -try using keyboard shortcut Ctrl + W, S but nothing shows up either -try customize keyboard shortcuts by Go to Tools > Options but can't find tool -try Using the Keyboard Shortcut to open Press Ctrl + Alt + L to opening the Solution Explorer to open explorer solution but doesn't work sorry for asking question that can be answered in google but none of them works for me:(
22 Replies
artya
artya17mo ago
Could you show the code in Program.cs? $code
MODiX
MODiX17mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat If your code is too long, post it to: https://paste.mod.gg/
Aimlatte
AimlatteOP17mo ago
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
artya
artya17mo ago
Does "Hello World!" show up after you dotnet run?
Aimlatte
AimlatteOP17mo ago
yes
artya
artya17mo ago
Ah, so you want to run code in a seperate file?
Aimlatte
AimlatteOP17mo ago
yes
Aimlatte
AimlatteOP17mo ago
this one is the code I want to run
artya
artya17mo ago
You can move the code inside of the Main method to the Main method inside of Program.cs I forgot about top-level statements, you can instead just copy the code inside of your exercise.cs "Main" method into Program.cs The dotnet run looks for the file named Program.cs in your project. It's the starting point of your program!
-try setting startup file by Right-click on the project but can't find "Set as Startup Project."
-try Open Solution Explorer by cliking View > Solution Explorer but can't find Explorer
-try using keyboard shortcut Ctrl+Alt+L but nothing shows up either
-try seurching for another version by going to view > Other Windows > Solution Explorer but can't find other windows
-try using keyboard shortcut Ctrl + W, S but nothing shows up either
-try customize keyboard shortcuts by Go to Tools > Options but can't find tool
-try Using the Keyboard Shortcut to open Press Ctrl + Alt + L to opening the Solution Explorer to open explorer solution but doesn't work
-try setting startup file by Right-click on the project but can't find "Set as Startup Project."
-try Open Solution Explorer by cliking View > Solution Explorer but can't find Explorer
-try using keyboard shortcut Ctrl+Alt+L but nothing shows up either
-try seurching for another version by going to view > Other Windows > Solution Explorer but can't find other windows
-try using keyboard shortcut Ctrl + W, S but nothing shows up either
-try customize keyboard shortcuts by Go to Tools > Options but can't find tool
-try Using the Keyboard Shortcut to open Press Ctrl + Alt + L to opening the Solution Explorer to open explorer solution but doesn't work
Are these all questions that need answering, or are they all related to Program.cs problem?
Aimlatte
AimlatteOP17mo ago
they are all related to Program.cs problem
artya
artya17mo ago
Ah ok, does your code run now?
Aimlatte
AimlatteOP17mo ago
not yet 😦
Aimlatte
AimlatteOP17mo ago
artya
artya17mo ago
In Program.cs remove line 2 through 6 and 14 trough 16 This should be the only code in Program.cs
using System;

Console.WriteLine("Enter input:");
string input = Console.ReadLine();
int loop = 1;
while (loop <= 10)
{
Console.WriteLine(inout + " loves me");
loop++
}
using System;

Console.WriteLine("Enter input:");
string input = Console.ReadLine();
int loop = 1;
while (loop <= 10)
{
Console.WriteLine(inout + " loves me");
loop++
}
Aimlatte
AimlatteOP17mo ago
public class don't needed?
artya
artya17mo ago
No All you need is this!
Aimlatte
AimlatteOP17mo ago
why does this class don't need public class and public static void main(String[] args) while other need?
ero
ero17mo ago
You had a link here which you removed that elaborates on the new console app template
Angius
Angius17mo ago
You cannot run individual files, just FYI Each project can have only a single Main() Whether it's explicitly written, or implicitly generated with top-level statements
Azrael
Azrael17mo ago
Uhh, what are you doing here?
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?