18
C# For Beginners - Getting Started
The tutorial is divided into a number of lessons. Each lesson introduces new concepts, and sample code is displayed to demonstrate those concepts.
If possible, try not to copy and paste the code. Instead, do your best to follow along by typing out each line. You will start building coding "muscle memory" this way.
At the end of each lesson the tutorial will test your knowledge, with questions or challenges for you to complete yourself. Make sure that before you tackle them, you fully understand what the question or the challenge is looking for.
Sometimes beginner programmers get stuck because they have gone through the material too fast, and accidentally formed an incorrect assumption because of a small error.
If you find yourself unable to solve a challenge, try going through the lesson again. Don't be afraid to go slowly - you might have missed something small. C# can be very strict, so you need to ensure that your code is precise and follows the exact structure expected.
You'll use Dotnet Interactive Notebooks as your workspace. It's an extension for Visual Studio Code (a code editor) that allows you to write and run C# code directly in the virtual notebook.
Tip
Visual Studio Code and the Dotnet Interactive Notebooks extension can be downloaded as a single installer. Go to https://dotnet.microsoft.com/learntocode and download the ".NET Coding Pack".
Download and install Visual Studio Code.
Launch Visual Studio Code. You'll see a screen similar to the one below.
Open the Extensions panel by clicking the button on sidebar, or from the menu bar by clicking on View then selecting Extensions.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--r85WfMFN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i4z3akfq7s1xg7bai0a9.png)
Type ".NET Interactive Notebooks" in the search bar on the Extensions panel. Click on the Install button to install the extension.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--wZVu962D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4bd3gkivp4xbxyug9ph.png)
Create a new Notebook by opening the Command Palette (Ctrl + Shift + P in Windows, Cmd + Shift + P on Mac) and selecting ".NET Interactive: Create new blank notebook".
You can also use the keyboard shortcut Ctrl + Shift + Alt + N (Windows) or Cmd + Shift + Alt + N (Mac) to create the notebook.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--JICwQwzu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dem9p945rsiewr27lj99.png)
Select "Create as .dib" in the next section.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--3ScOi1HM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e1e4ladm4b2yuki6ptyy.png)
Next, select "C#" as the language.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--UBJOzyrf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzwkjya37arpbvx25jnd.png)
The .NET Interactive files will download if they haven't been installed yet.
When you see this screen, your notebook is ready! Write your C# code in the box.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--1x6hvqZC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47znuste89a43f7jzqtx.png)
To run the code, click on the Execute button on the left-hand side, or press Ctrl + Alt + Enter (Windows) / Cmd + Alt + Enter (Mac).
![](https://res.cloudinary.com/practicaldev/image/fetch/s--IByQTWmr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ijt4i8dtkweptt7fuf1.png)
18