C
C#2y 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
artya2y ago
Could you show the code in Program.cs? $code
MODiX
MODiX2y 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
AimlatteOP2y 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
artya2y ago
Does "Hello World!" show up after you dotnet run?
Aimlatte
AimlatteOP2y ago
yes
artya
artya2y ago
Ah, so you want to run code in a seperate file?
Aimlatte
AimlatteOP2y ago
yes
Aimlatte
AimlatteOP2y ago
this one is the code I want to run
artya
artya2y 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
AimlatteOP2y ago
they are all related to Program.cs problem
artya
artya2y ago
Ah ok, does your code run now?
Aimlatte
AimlatteOP2y ago
not yet 😦
Aimlatte
AimlatteOP2y ago
artya
artya2y 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
AimlatteOP2y ago
public class don't needed?
artya
artya2y ago
No All you need is this!
Aimlatte
AimlatteOP2y ago
why does this class don't need public class and public static void main(String[] args) while other need?
ero
ero2y ago
You had a link here which you removed that elaborates on the new console app template
Angius
Angius2y 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
Azrael2y ago
Uhh, what are you doing here?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Accord
Accord2y 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?