C
C#5mo ago
MorryMar

✅ how do i install C# into visual studio

im tryna learn c# but idk how to make a cs file whenever i want to
32 Replies
mtreit
mtreit5mo ago
Not entirely sure what you're asking. When you install Visual Studio just choose .NET Development as one the workloads. Assuming you mean Visual Studio and not Visual Studio Code.
MorryMar
MorryMar5mo ago
no vsc
MorryMar
MorryMar5mo ago
what i meant
No description
MorryMar
MorryMar5mo ago
is like how to make vsc make files like these i installed it a long ago
mtreit
mtreit5mo ago
I usually use dotnet new console --name MyConsoleApp in a terminal window to create a new project.
MorryMar
MorryMar5mo ago
No description
MorryMar
MorryMar5mo ago
No description
MorryMar
MorryMar5mo ago
and is the code supposed to work wit only 1 line?
mtreit
mtreit5mo ago
Yes, recent versions of C# introduced a feature called "top level statements" that is supposed to make it more user friendly for beginners. Although in practice it seems to just confuse people.
MorryMar
MorryMar5mo ago
No description
MorryMar
MorryMar5mo ago
while its in another hard
No description
mtreit
mtreit5mo ago
$vscode
MODiX
MODiX5mo ago
Follow the instructions here on getting started with DevKit for C# in VSCode: https://code.visualstudio.com/docs/csharp/get-started
Get started with C# and .NET in Visual Studio Code
Getting Started with C# and .NET Development in Visual Studio Code
mtreit
mtreit5mo ago
BTW if you want the old style that has a namespace and class and Main method you can do this:
dotnet new console --name MyConsoleApp2 --use-program-main
dotnet new console --name MyConsoleApp2 --use-program-main
Make sure in VSCode that you open the folder containing the csproj Don't use Open File, use Open Folder.
Angius
Angius5mo ago
Also, try to avoid special characters like # in your paths
MorryMar
MorryMar5mo ago
is this normal?
No description
MorryMar
MorryMar5mo ago
No description
mtreit
mtreit5mo ago
Looks normal I think I don't ever run programs from in VSCode
MorryMar
MorryMar5mo ago
No description
MorryMar
MorryMar5mo ago
all of this is required for just 1 line of code? im so confused
mtreit
mtreit5mo ago
C# isn't a scripting language where you just feed your .py file to a program. You are building an assembly (DLL) file and that process requires compiling all of your source code files. The stuff under obj is temporary stuff that the compiler produces. As part of the compilation process. You can generally ignore that.
MorryMar
MorryMar5mo ago
so basically i just ignore it
mtreit
mtreit5mo ago
Yeah, use a .gitignore file. So you don't check that stuff in to source control.
MorryMar
MorryMar5mo ago
but is there a way to remove the orange lines? this one how if i may ask
mtreit
mtreit5mo ago
You can type the path to the program in the terminal and it will run without the build output, if you've already compiled it.
dotnet new gitignore
dotnet new gitignore
MorryMar
MorryMar5mo ago
dont understand
mtreit
mtreit5mo ago
No description
mtreit
mtreit5mo ago
That's if you just want to run the program directly. Without debugging it or rebuilding it If you start it under the debugger in VSCode I think you will probably see a bunch of output from the build and whatnot as well as the output from your program. There are probably ways to tell it to use a separate terminal window for the program but I don't use VSCode enough to say.
MorryMar
MorryMar5mo ago
ooh ok thanks man sorry for wasting ur time
mtreit
mtreit5mo ago
Good luck learning C#!
MorryMar
MorryMar5mo ago
thank u man im watching bro codes c# full course theni will do a bit of stuff with it then go to unity
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View