c#repl
REPLs are great! REPL stands for Read–eval–print loop and is pronounced "REP-L" quickly, like "battle." Lots of languages and environments have interactive coding and REPLS at their heart and have for years. C# and F# do also, but a lot of people don't realize there are REPLs available!
REPL很棒! REPL代表“读取-评估-打印”循环,并像“战斗”一样Swift发音为“ REP-L”。 许多语言和环境的核心都是交互式编码和REPLS,并且已经使用了很多年。 C#和F#也可以,但是很多人没有意识到有REPL可用!
In 2013 once the Roslyn open source C# compiler started to mature, Glenn Block and many friends made ScriptCS. It now lives at http://scriptcs.net and has a great GitHub and active community. The Mono project has also had a REPL for a very long time.
在2013年Roslyn开源C#编译器开始成熟后, Glenn Block和许多朋友创建了ScriptCS 。 现在,它位于http://scriptcs.net,并拥有一个很棒的GitHub和活跃社区。 Mono项目也有很长一段时间的REPL 。
You can install ScriptCS in minutes with the Chocolatey Package Manager or OneGet with Chocolatey on Windows 10. In the screenshot above I'm writing code at the command prompt, making mistakes, and fixing them. It's a great way to learn and play with C#, but it's also VERY powerful. You can create C# Scripts (.csx files) kind of like PowerShell but it's just C#!
您可以在Windows 10上使用Chocolatey软件包管理器在几分钟之内安装ScriptCS,或者在Chocolatey软件包管理器中安装OneGet与Chocolatey 。 在上面的屏幕快照中,我正在命令提示符下编写代码,进行错误修复。 这是学习和玩C#的好方法,但它也非常强大。 您可以创建类似于PowerShell的C#脚本(.csx文件),但它只是C#!
The Visual Studio team meets/met with the ScriptCS folks in the open and even publishes their meeting notes on GitHub! In May of last year they got ScriptCS working in OmniSharp and Visual Studio Code, which is amazing. There's a great set of directions here on how to set up ScriptCS in Visual Studio Code and the code is moving fast on GitHub.
Visual Studio团队公开地与ScriptCS人员会面/交流,甚至在GitHub上发布他们的会议记录! 去年5月,他们使ScriptCS在OmniSharp和Visual Studio Code中工作,这真是了不起。 这里有很多关于如何在Visual Studio Code中设置ScriptCS的指导,并且代码在GitHub上正在快速发展。
Visual Studio 2015 Update 1 has REPLs within the IDE itself. If you have Visual Studio 2015, make sure you've updated to Update 1. If you don't have VS, you can get the free Visual Studio Community at http://visualstudio.com/free.
Visual Studio 2015 Update 1在IDE本身中具有REPL。 如果您拥有Visual Studio 2015,请确保已更新为Update 1 。 如果您没有VS,则可以从http://visualstudio.com/free获得免费的Visual Studio社区。
VS ships a command line RELP called "CSI" that you can use to run ".csx" scripts as well. Turns out the source code for CSI is basically nothing! Check it out at http://source.roslyn.io/#csi/Csi.cs and you can see how easy it would be for you to add scripting (interactive or otherwise) to your own app.
VS附带了一个称为“ CSI”的命令行RELP,您也可以使用它运行“ .csx”脚本。 原来CSI的源代码基本上什么都没有! 在http://source.roslyn.io/#csi/Csi.cs上进行检查,您会发现将脚本(交互或其他方式)添加到自己的应用中会多么容易。
There's a great C# Interactive Walkthrough by Kasey Uhlenhuth that you should take a moment and play with. She's the Program Manager on this feature and also has a great video on Channel 9 on how to use the C# Interactive REPL.
Kasey Uhlenhuth提供了很棒的C#交互式演练,您应该花点时间来玩。 她是该功能的程序经理,并且在第9频道上有一段精彩的视频,介绍如何使用C#Interactive REPL 。
Of course, F# has always had a REPL called "fsi.exe" that also ships with VS. You may have this on your PATH and not realize it, in fact. F# script files are ".fsx" so there's a nice symmetry with scripting and REPLs available in both languages, either in VS itself, or at the command line.
当然,F#一直都有一个VS附带的称为“ fsi.exe”的REPL。 实际上,您可能在PATH上有此选项,而没有意识到。 F#脚本文件是“ .fsx”,因此在VS本身或在命令行中,两种语言都可以使用脚本和REPL很好地对称。
F#'s REPL is also inside VS, right here next to the C# Interactive Window.
F#的REPL也在VS内部,就在C#交互式窗口旁边。
These are all great options for learning and exploring code in a more interactive way than the traditional "write, compile, wait, run" that so many of us are used to.
与我们很多人习惯的传统“编写,编译,等待,运行”方式相比,这些都是以更具交互性的方式学习和探索代码的绝佳选择。
Let's hear in the comments how (or if!) you're using REPLs like these two make your programming life better.
让我们在评论中听听您如何(或是否!)使用这两种REPL,从而使您的编程生活变得更好。
Sponsor: Big thanks to Wiwet for sponsoring the feed this week. Build responsive ASP.NET web appsquickly and easily using C# or VB for any device in 1 minute. Wiwet ASP.Net templates are integrated into Visual Studio for ease of use. Get them now at Wiwet.com.
赞助商:非常感谢Wiwet本周赞助了feed。 在1分钟内使用C#或VB为任何设备快速轻松地构建响应式ASP.NET Web应用程序。 Wiwet ASP.Net模板已集成到Visual Studio中,以易于使用。 立即在Wiwet.com上获取它们。
翻译自: https://www.hanselman.com/blog/interactive-coding-with-c-and-f-repls-scriptcs-or-the-visual-studio-interactive-window
c#repl