C# For Beginners - Getting Started
Tags: csharp, vscode, dotnet, beginners
Published: 2021-07-11 12:12:09

## How The Tutorial Works

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.

## Set Up Your Workspace

You'll use [Dotnet Interactive Notebooks](https://github.com/dotnet/interactive) 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](https://dotnet.microsoft.com/learntocode) and download the ".NET Coding Pack".

Download and install [Visual Studio Code](https://code.visualstudio.com/).
![Visual Studio Code website](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mk7v1hb87zigeal2k2md.png)

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_.

![Visual Studio Code, showing the Extensions panel button](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.

![.NET Interactive Notebooks in Extensions](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.

![Create new blank notebook](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dem9p945rsiewr27lj99.png) 

 Select "Create as .dib" in the next section.

![Create as .dib](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e1e4ladm4b2yuki6ptyy.png) 

Next, select "C\#" as the language.

![Select C# as the language](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. 

![Dotnet Interactive is ready](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\).

![How to execute the code in the code box](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ijt4i8dtkweptt7fuf1.png)