有时候只想使用 C# 验证或计算一些简单的事情,如何快速实现?

linqpad 是个不错的方案,LINQPad - The .NET Programmer's Playground,这里介绍 dotnet-script

dotnet-script 为何物?

Run C# scripts from the .NET CLI, define NuGet packages inline and edit/debug them in VS Code - all of that with full language services support from OmniSharp.

filipw/dotnet-script: Run C# scripts from the .NET CLI.

准备工作

VS Code,安装插件 C#Code Runner

如何使用

安装

dotnet tool install -g dotnet-script

创建 .csx 文件

#!dotnet-script
// #!dotnet-script  // windows
// #!/usr/bin/env dotnet-script  // linux

Console.WriteLine("hello dotnet");

然后就可以运行了,就这么简单。

使用 dotnet-script 将 C# 作为脚本工具使用

更多参考

.NET Core脚本工具dotnet-script - LamondLu - 博客园
Azure Functions C# 脚本开发人员参考 | Microsoft Docs

其它

VScode 中 code runner 插件乱码问题

进入 File - > Preference -> setting, 然后在输入框搜索 settings.json 文件,选择编辑,然后在右边user setting 中增加即可

 "code-runner.runInTerminal": true,

VScode 中 code runner 插件乱码问题_kzcming的博客-CSDN博客_code runner乱码

在线 .net runner

https://try.dot.net

相关文章:

  • 2021-10-29
  • 2021-05-17
  • 2022-12-23
  • 2021-10-04
  • 2021-12-05
  • 2021-05-19
  • 2021-06-29
  • 2021-05-27
猜你喜欢
  • 2021-12-13
  • 2022-12-23
  • 2021-06-13
  • 2021-09-15
  • 2021-11-06
相关资源
相似解决方案