Execute a piece of C# code anytime in VS Code using .NET Interactive Notebooks

.Net Interactive Notebooks is an extension being developed by Microsoft, and this extension adds support for using .NET Interactive in a Visual Studio Code notebook.

The source code to this extension is available on https://github.com/dotnet/interactive and licensed under the MIT license.

Getting Started

  1. Install the latest Visual Studio Code.
  2. Install the latest .NET 5 SDK
  3. Install the .NET Interactive Notebooks extension from the marketplace.

Before this we used to go and find some online tools or LINQ Pad to run our C# code to check the output. But creating a sample project just to check a logic has never been easy. But now this has been made even simpler with the .NET Interactive.

Basically what it does is allow you to write your code and execute there itself, to check the output.

Screenshot of a Vs Code .Net Interactive Tab.

In the above screenshot we can see its so easy to just print Hello world there itself, This is quick and save a lot of time. You can also save this file and load and run the part of code you want to execute. You could also share this file with some one and make it easier to just execute the part of code he/she wants.

How to Use the Extention ?

Once you have installed the extension press Ctrl + Shift + P to open the Command tab and select the option .NET Interactive Create new blank notebook as shown below. This will create a new notebook which you can save and share.

Hope you loved this insight.

Happy Coding.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: