Multi-language notebooks with Jupyter

March 14, 2023 ยท View on GitHub

With .NET Interactive you can create notebooks that use different languages together. A notebook written using the .ipynb file format has a default language, and in frontends with no cell kernel selector (e.g. JupyterLab), any cell whose language isn't set will use the notebook's default. In JupyterLab, the default is chosen when you create a new notebook:

When a notebook is opened in JupyterLab, its default language is displayed in the upper right corner. In this example, the default language is C#:

But every .NET Interactive notebook is capable of running multiple languages. You can specify the language for a cell using one of a number of magic commands. For example, though the default language of the following notebook is F#, it's possible to run code in C# using the #!csharp magic command and in PowerShell using the #!pwsh magic command: