Write Code
Once you have the project setup, the next step is to start writing code. To do this we need a text editor. While you can use any text editor, you want one designed to work with source code. This will give you a whole lot of features designed to make editing code easier.
For now we will just focus on the tool itself, and we will look at the details of the code in the next part.
We will be using Visual Studio Code (VS Code). This is another great, free, open-source tool from Microsoft. It works well with many languages, including the C# language which we will start with.
Once you have created a new project using dotnet
, you can open it in VS Code. It is important to always open the folder that contains your project. This allows VS Code to read your csproj file to get the settings it needs. You can do this from the terminal as shown below.
This opens the current folder (.) in VS Code. It is always best to open the folder, rather than the source file directly, as this gives the editor the bigger picture of your project.
The following image shows what you will see in VS Code. In the left-hand side of the VS Code window you will see the list of files in your project folder. You can open a file by double-clicking on it in the explorer on the left. For example, double-clicking on Program.cs will open it in the source code editor as shown below.
Once you have updated the code, you need to save it before you can build and run it. You can click Save in the File menu or by pressing the Ctrl-S (or Cmd-S on macOS) shortcut keys.
Once the code is saved, you are now ready to build and run your program!