C
C#10mo ago
Planet

How do i make a c# file in vscode?

i am COMPLETELY new to c#, as u can tell
11 Replies
Thinker
Thinker10mo ago
Step 1: do you have the .NET SDK installed?
Thinker
Thinker10mo ago
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.
Thinker
Thinker10mo ago
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. - ??? - profit
Planet
PlanetOP10mo ago
alr 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
Thinker
Thinker10mo ago
ah
Thinker
Thinker10mo ago
You'll need this extension for C# support to work properly.
C# Dev Kit - Visual Studio Marketplace
Extension for Visual Studio Code - Official C# extension from Microsoft
Thinker
Thinker10mo ago
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 tutorial
Planet
PlanetOP10mo ago
alr thanks for the notes 💯🤝 imma have a long night of c# fr 😭
Thinker
Thinker10mo ago
Yeah, it can be intimidating on how to start It's a lot more complex to set up than something like Python or Javascript
Planet
PlanetOP10mo ago
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
Want results from more Discord servers?
Add your server