> The **Polyglot Notebooks** extension was previously named **.NET Interactive Notebooks**. But it retains its original identifier: `ms-dotnettools.dotnet-interactive-vscode`. Read more here: https://devblogs.microsoft.com/dotnet/dotnet-interactive-notebooks-is-now-polyglot-notebooks/#why-the-name-change
Polyglot Notebooks makes writing code even easier than top-level programs. It requires Visual Studio Code, so if you did not install it and the Polyglot Notebooks extension earlier, then please install them now.
Visual Studio 2022 does have its own extension for notebooks named **Notebook Editor** that was created by Microsoft's machine learning team. It is not as mature as the **Polyglot Notebooks** extension for Visual Studio Code, so I do not recommend it. You can learn more and install **Notebook Editor** from the following link: https://marketplace.visualstudio.com/items?itemName=MLNET.notebook
> `.dib` is an experimental file format defined by Microsoft to avoid confusion and compatibility issues with the `.ipynb` format used by Python interactive notebooks. The file extension was historically only for Jupyter notebooks that can contain an interactive (I) mix of data, Python code (PY), and output in a notebook file (NB). With .NET Interactive Notebooks, the concept has expanded to allow a mix of C#, F#, SQL, HTML, JavaScript, Markdown, and other languages. `.dib` is polyglot, meaning it supports mixed languages. Conversion between the `.dib` and `.ipynb` file formats is supported.
5. Select C# for the default language for code cells in the notebook.
1. Navigate to **View** | **Output** and then select **Polyglot Notebook : diagnostics** in the drop-down list. Please be patient. It can take a few minutes for the notebook to appear because it must start up a hosting environment for .NET. If nothing happens after a few minutes, then close Visual Studio Code and restart it.
2. Once the Polyglot Notebooks extension is downloaded and installed, the **OUTPUT** window diagnostics will show that a kernel process has started (your process numbers will be different from the output below), as shown in the following output:
1. The first cell should already be set to **C# (Polyglot Notebook)**, but if it is set to anything else, then click the language selector in the bottom-right corner of the code cell and then select **C# (Polyglot Notebook)** as the language mode for that cell, and note your other choices of language for a code cell, as shown in *Figure 1.17*:
2. Inside the **C# (Polyglot Notebook)** code cell, enter a statement to output a message to the console, and note that you do not need to end the statement with a semicolon, as you normally would in a full application, as shown in the following code:
When you have multiple code cells in a notebook, you must execute the preceding code cells before their context becomes available in subsequent code cells:
1. At the bottom of the notebook, add a new code cell, and then type a statement to declare a variable and assign an integer value, as shown in the following code:
```cs
int number = 8;
```
2. At the bottom of the notebook, add a new code cell, and then type a statement to output the number variable, as shown in the following code:
3. Note the second code cell does not know about the number variable because it was defined and assigned in another code cell, aka context, as shown in *Figure 1.20*:
4. In the first cell, click the **Execute Cell** button to declare and assign a value to the variable.
5. In the second cell, click the **Execute Cell** button to output the number variable, and note that this works. (Alternatively, in the first cell, you can click the **Execute Cell and Below** button in the mini-toolbar in the top-right corner of that cell.)
> **Good Practice**: If you have related code split between two or more cells, remember to execute the preceding cells before executing the subsequent cells. At the top of the notebook, there are the following buttons: **Clear Outputs** and **Run All**. These are very handy because you can click one and then the other to ensure that all code cells are executed properly.
Throughout the rest of the chapters, I will not give explicit instructions to use notebooks, but the GitHub repository for the book has solution notebooks when appropriate. I expect many readers will want to run my pre-created notebooks for language and library features covered in Chapters 1 to 11 that they want to see in action and learn about without having to write a complete application: