C
C#12mo ago
♫Woozy♫

I can't even run my code.

Hi! I'm trying to start learning C# in visual studio community but my visual studio just doesn't look the same as the people in youtube tutorials. I can't even press F5 to run a simple Hello World... Any idea on what might be the problem?
46 Replies
Pobiega
Pobiega12mo ago
It looks like you don't have any projects added to your solution. Did you perhaps open a .cs file directly inside VS instead of opening the .csproj? C# is project based, so you must open a project file
♫Woozy♫
♫Woozy♫12mo ago
it says Program.cs in the top left should it say .csproj instead there?
Pobiega
Pobiega12mo ago
No, I just think you opened the wrong file when you started Visual Studio as said, C# is project based its not like python or JS where you can run an individual file
♫Woozy♫
♫Woozy♫12mo ago
When I launch vscommunity i press the create a new project
♫Woozy♫
♫Woozy♫12mo ago
♫Woozy♫
♫Woozy♫12mo ago
then chose Console App
♫Woozy♫
♫Woozy♫12mo ago
Pobiega
Pobiega12mo ago
Okay, seems good
♫Woozy♫
♫Woozy♫12mo ago
♫Woozy♫
♫Woozy♫12mo ago
i use net 6.0, it's the standard option
Pobiega
Pobiega12mo ago
No reason not to use 7.0, but thats a minor issue
♫Woozy♫
♫Woozy♫12mo ago
and when it opens i get this:
♫Woozy♫
♫Woozy♫12mo ago
Pobiega
Pobiega12mo ago
hm okay thats not how its supposed to look if you look top right, you see it says "0 projects"
♫Woozy♫
♫Woozy♫12mo ago
yeah
Pobiega
Pobiega12mo ago
okay lets try doing it via the terminal open up a command prompt or terminal and navigate to where you want the code to be
♫Woozy♫
♫Woozy♫12mo ago
how do I do that?
Pobiega
Pobiega12mo ago
WIN+R and type "cmd"
♫Woozy♫
♫Woozy♫12mo ago
oooh aight, then?
Pobiega
Pobiega12mo ago
well, where do you want the code to be on your computer? Im guessing your prompt says something like C:\Users\<yourusername>
♫Woozy♫
♫Woozy♫12mo ago
don't i write the code in visual studio community yeah it does
Pobiega
Pobiega12mo ago
Are you aware of how the computer stores files on your harddrives? your code is files. on your harddrives.
♫Woozy♫
♫Woozy♫12mo ago
ooh yeah
Pobiega
Pobiega12mo ago
I keep all my code in D:\Code, but if you dont have a second drive you can just put it on C
♫Woozy♫
♫Woozy♫12mo ago
yeah i just have an ssd so it all gets stored on my ssd C drive
Pobiega
Pobiega12mo ago
okay great so lets do cd .. twice then mkdir code then cd code
♫Woozy♫
♫Woozy♫12mo ago
done
Pobiega
Pobiega12mo ago
and your prompt says C:\code now?
♫Woozy♫
♫Woozy♫12mo ago
yes
Pobiega
Pobiega12mo ago
great then do dotnet new console -n MyTestProject
♫Woozy♫
♫Woozy♫12mo ago
Pobiega
Pobiega12mo ago
oooh you dont have any SDKs installed lets verify do dotnet --info and show me what it says
♫Woozy♫
♫Woozy♫12mo ago
Pobiega
Pobiega12mo ago
two dashes
♫Woozy♫
♫Woozy♫12mo ago
Pobiega
Pobiega12mo ago
Ah, you have installed an x86 version lets swap to the x64
♫Woozy♫
♫Woozy♫12mo ago
how do i do that?
Pobiega
Pobiega12mo ago
are you able to screenshare?
♫Woozy♫
♫Woozy♫12mo ago
yeah :)
Pobiega
Pobiega12mo ago
its a bit tricky to explain over text #dev-vc-1 $helloworld
Pobiega
Pobiega12mo ago
👻
♫Woozy♫
♫Woozy♫12mo ago
Tja. Behöver jag ha med "private static void" grejen och internal class program i min kod? för det är något error med internal class Program står det
♫Woozy♫
♫Woozy♫12mo ago
Pobiega
Pobiega12mo ago
English only in written channels. You seem to have two Program classes in the same namespace thats not allowed and the declaring of a class and main method CAN be skipped, but I recommend against it as a beginner since thats unique to just the main method, everwhere else you still need to make classes
♫Woozy♫
♫Woozy♫12mo ago
Hi! I got help from some people in vc with the program issue and it's fixed now. I'll look up a tutorial on how to declare it :)