Jupyter Notebook is popular platform to write and execute your code. However, not many C# developer use it as we have Visual Studio as our preferred IDE.
However, according to Introducing the Jupyter Extension for VS Code article, VS Code start supporting Jupyter Notebook more and more these days. So it's time to try C# on Jupyter Notebook.
.NET Interactive Notebooks
.NET Interactive Notebooks is an extension for VS Code, and it's easy to start using with 3 steps.
1. Install Visual Studio Code Insiders as it's preview feature at the moment. By the time you read this article, it would be included in normal VS Code though.
2. Install .NET Core SDK, which I believe all C# developer already have. The official page says to install .NET Core 3.1.
3. Install .NET Interactive Notebooks extension.
Just restart VS code to complete the installation.
Create your first notebook
Now you're ready to use it. Go to command palette and select "Create new blank notebook"
It may take a bit of time for initial notebook creation, so just wait until you see new notebook. Once it's ready, you see the notebook like below.
Type your code and execute by either click arrow icon or Shift+Enter.
Of course you can define class and use it.
.NET 5?
.NET 5 GA this week! Yay! But the extension supports .NET Core 3.1 at the moment. Let's wait until it support .NET 5. Check GitHub issue for more detail. I cannot wait to try Record type in notebook :)
Other than C#?
Yes, the extension supports various other dotnet related languages.
For example, you can write and execute PowerShell as well :)
Top comments (5)
Nice 😄, Thanks for sharing.
It's very nice.
But i have installed dotnet sdk 5 and dotnet sdk3.1, from commandline is it possible to install dotnet notebook by switching to dotnet 3.1
I don't have trouble using it with both version installed. Any issue you are facing?
I am not able to install dotnet using below command using powershell.
dotnet tool install --global Microsoft.dotnet-interactive
i am getting below error still even through extension is installed.
Command '.NET Interactive: Create new blank notebook' resulted in an error (command 'dotnet-interactive.newNotebook' not found)
hm.. can you try
--fx-version
to specify 3.1?