❔ 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
Could you show the code in Program.cs?
$code
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/Does "Hello World!" show up after you
dotnet run
?yes
Ah, so you want to run code in a seperate file?
yes
this one is the code I want to run
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!
Are these all questions that need answering, or are they all related to Program.cs
problem?they are all related to Program.cs problem
Ah ok, does your code run now?
not yet 😦
In
Program.cs
remove line 2 through 6 and 14 trough 16
This should be the only code in Program.cs
public class don't needed?
No
All you need is this!
why does this class don't need public class and public static void main(String[] args) while other need?
You had a link here which you removed that elaborates on the new console app template
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 statementsUhh, what are you doing here?
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
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.