C
C#10mo 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
mtreit10mo 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
MorryMarOP10mo ago
no vsc
MorryMar
MorryMarOP10mo ago
what i meant
No description
MorryMar
MorryMarOP10mo ago
is like how to make vsc make files like these i installed it a long ago
mtreit
mtreit10mo ago
I usually use dotnet new console --name MyConsoleApp in a terminal window to create a new project.
MorryMar
MorryMarOP10mo ago
No description
MorryMar
MorryMarOP10mo ago
No description
MorryMar
MorryMarOP10mo ago
and is the code supposed to work wit only 1 line?
mtreit
mtreit10mo 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
MorryMarOP10mo ago
No description
MorryMar
MorryMarOP10mo ago
while its in another hard
No description
mtreit
mtreit10mo ago
$vscode
MODiX
MODiX10mo 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
mtreit10mo 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
Angius10mo ago
Also, try to avoid special characters like # in your paths
MorryMar
MorryMarOP10mo ago
is this normal?
No description
MorryMar
MorryMarOP10mo ago
No description
mtreit
mtreit10mo ago
Looks normal I think I don't ever run programs from in VSCode
MorryMar
MorryMarOP10mo ago
No description
MorryMar
MorryMarOP10mo ago
all of this is required for just 1 line of code? im so confused
mtreit
mtreit10mo 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
MorryMarOP10mo ago
so basically i just ignore it
mtreit
mtreit10mo ago
Yeah, use a .gitignore file. So you don't check that stuff in to source control.
MorryMar
MorryMarOP10mo ago
but is there a way to remove the orange lines? this one how if i may ask
mtreit
mtreit10mo 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
MorryMarOP10mo ago
dont understand
mtreit
mtreit10mo ago
No description
mtreit
mtreit10mo 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
MorryMarOP10mo ago
ooh ok thanks man sorry for wasting ur time
mtreit
mtreit10mo ago
Good luck learning C#!
MorryMar
MorryMarOP10mo 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 User10mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server