Interactive. Net

Interactive. Net

Interactive means that you can directly run the code after entering the code, and then continue to enter the running code.

最后更新 5/9/2022 6:25 AM
Erik Xu 跬步之巅
预计阅读 3 分钟
分类
.NET
标签
.NET C#

1. noun analysis

  1. interactive

Interactive means that you can directly run the code after entering the code, and then continue to enter the running code.

  1. Interactive. Net

.Net 是一种编译型语言,不像 python 这类的脚本型语言,可以边输入代码边运行结果。幸运的是,软微推出了 interactive 这个项目,使交互式 .Net 成为可能。

  1. The role of interactive. Net

交互式 .Net 可以解析 markdown,执行本地指令,如 powershell,执行 .Net 代码,因此,非常适用于教案编写,或者关键代码记录。并且生成的 ipynb 文件可上传到 GitHub 等平台,非常方便查阅。

2. installation settings

需要先安装 Visual Studio Code.NET 5 及以上版本,然后在 Visual Studio Code 中安装 .NET Interactive Notebooks 插件,可以在 Visual Studio Code 中搜索 .NET Interactive Notebooks 进行安装:

3. use of presentation

  1. New Interaction

使用热键 Ctrl+Shift+P,然后选择 .NET Interactive: Create new blank notebook`

或者直接使用热键 Ctrl+Shift+Alt+N,然后选择 Create as '.ipynb'

开发语言选 C#

  1. Analyze Markdown

输入一段 markdown 内容,并在右下角选择 Markdown

使用热键 Alt+Enter 查看结果

  1. Executing C#code

输入一段 C# 代码,并在右下角选择 C#

使用热键 Alt+Enter 或者点击左边的“运行”按钮查看运行结果

可以通过 using 关键字引用相关依赖

  1. execute a native instruction

输入一段本地指令,并在右下角选择 PowerShell,使用热键 Alt+Enter 或者点击左边的“运行”按钮查看运行结果

  1. Get the. Net version through code

  1. Save ipynb file and upload it to GitHub

使用热键 Ctrl+Sipynb 文件保存到本地,以后可以使用 Visual Studio Code 打开查看并重新运行代码

然后把 ipynb 文件上传到 GitHub

可以通过 https://github.com/ErikXu/Blogs/blob/master/ipynb/dotnet-interactive.ipynb 查看示例

4. Reference summary

以上就是本文希望分享的内容,其中 interactiveGitHub 地址为:https://github.com/dotnet/interactive

If you have any questions, you are welcome to leave a message and communicate on the public account.

Keep Exploring

延伸阅读

更多文章
同分类 / 同标签 4/22/2026

Support for. NET by operating system versions (250707 update)

Use virtual machines and test machines to test the support of each version of the operating system for. NET. After installing the operating system, it is passed by measuring the corresponding running time of the installation and being able to run the Stardust Agent.

继续阅读
同分类 / 同标签 2/7/2026

Summary of experience in using AOT

From the very beginning of project creation, you should develop a good habit of conducting AOT release testing in a timely manner whenever new features are added or newer syntax is used.

继续阅读