F# 有一个 REPL(读取-求值-打印循环)F# Interactive,C:\Program Files (x86)\Microsoft F#\v4.0\Fsi.exe
。
我知道 C# 现在有自己的交互式 REPL,与 Roslyn 一起发布.如何在 Visual Studio 外部打开? csi.exe
在哪里?
最佳答案
C# Interactive 窗口和 csi.exe REPL 已添加到 Visual Studio 2015 Update 1(强调我的):
Introducing Interactive
The Interactive Window is back! The C# Interactive Window returns in Visual Studio 2015 Update 1 along with a couple other interactive treats:
C# Interactive. The C# Interactive window is essentially a read-eval-print-loop (REPL) that allows you to play and explore with .NET technologies while taking advantage of editor features like IntelliSense, syntax-coloring, etc. Learn more about how to use C# Interactive on Channel 9 or by reading our beginner’s walkthrough.
csi. If you don’t want to open Visual Studio to play around with C# or run a script file, you can access the interactive engine from the Developer Command Prompt. Type
csi /path/myScript.csx
to execute a script file or type simplycsi
to drop inside the command-line REPL.Scripting APIs. The Scripting APIs give you the ability to execute snippets of C# code in a host-created execution environment. You can learn more about how to create your own C# script engine by checking out our code samples.
参见 What’s New in Visual Studio 2015 Update 1 for .NET Managed Languages .
https://www.visualstudio.com/en-us/news/vs2015-update1-vs.aspx
>csi
Microsoft (R) Visual C# Interactive Compiler version 1.1.0.51109
Copyright (C) Microsoft Corporation. All rights reserved.
Type "#help" for more information.
> #help
Keyboard shortcuts:
Enter If the current submission appears to be complete, evaluate it. Otherwise, insert a new line.
Escape Clear the current submission.
UpArrow Replace the current submission with a previous submission.
DownArrow Replace the current submission with a subsequent submission (after having previously navigated backwards).
REPL commands:
#help Display help on available commands and key bindings.
Script directives:
#r Add a metadata reference to specified assembly and all its dependencies, e.g. #r "myLib.dll".
#load Load specified script file and execute it, e.g. #load "myScript.csx".
>
> Enumerable.Range(10)
(1,12): error CS7036: There is no argument given that corresponds to the required formal parameter 'count' of 'Enumerable.Range(int, int)'
> Enumerable.Range(1, 10)
RangeIterator { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
关于Visual Studio 之外的 C# REPL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10980596/