11 Replies
Step 1: do you have the .NET SDK installed?
Microsoft
Download .NET (Linux, macOS, and Windows)
Free downloads for building and running .NET apps on Linux, macOS, and Windows. Runtimes, SDKs, and developer packs for .NET Framework, .NET, and ASP.NET.
If you don't have the SDK, download and install it.
Once you have the SDK installed:
- Open your terminal of choice and run
dotnet new console -n "MyAwesomeProject"
- run cd MyAwesomeProject
- Run dotnet run
, which should display the text Hello, World!
. If it does this, you've installed everything properly.
- Now run code .
, or just open the MyAwesomeProject
folder in VSCode.
- Congratulations! The folder contains two files: a Program.cs
which is the file you'll be writing your code in, and a MyAwesomeProject.csproj
file which is just some metadata about the project itself (which you don't need to worry about).
- Start editing Program.cs
and do whatever you want.
- ???
- profitalr thanks, js one more question:
whats the best version of vscode rn that supports the sdk? i got 1.84.2 and i dont see a supported version
or am i tweaking
ah
C# Dev Kit - Visual Studio Marketplace
Extension for Visual Studio Code - Official C# extension from Microsoft
nevermind it's this one
Also, some notes about how C# works:
-
Program.cs
is the main file of your project, it contains the code that will be run first when you run your project.
- There can only be one file in the project directly containing statements (like Console.WriteLine
) outside a class
. You can have more than one file in your project obviously, but those have to contain classes and cannot directly contain code.
- If you want to some other piece of code to run when you run your project, you'll have to create a new project.
And lastly, $helloworld is a great start if you're looking for a more thorough tutorialalr thanks for the notes 💯🤝
imma have a long night of c# fr 😭
Yeah, it can be intimidating on how to start
It's a lot more complex to set up than something like Python or Javascript
yep i tried python and settled in pretty quickly cuz its really easy to read, doubt im gonna be as fast with this one tbh
just looking at basic c# code intimidates me lmao